SeanLetendre SeanLetendre - 1 year ago 66
Java Question

javac's recognition of packages

I have a package LMath with a class LMatrix. LMatrix has a method public LMatrix getInverse() that throws LDimensionException.
The first line in both of these files is:

package com.kavricious.LMath;

Compiling this class in jGrasp results in no problem, but if I enter

PS C:\programming\java\javaprojects\com\kavricious\lmath> javac

in Windows PowerShell, the stack trace reads: error: cannot find symbol
public LMatrix getInverse() throws LDimensionException{
symbol: class LDimensionException
location: class LMatrix

how do I tell javac to recognize members as in the same package?

Answer Source
C:\programming\java\javaprojects\com\kavricious\lmath> javac

That should be

C:\programming\java\javaprojects> javac com\kavricious\LMath\

And similarly for all other Java files: compile from the root of the package hierarchy, and name the entire path to the .java file. Then the object files will be put in the right place, and found, and the ither .java files will be compiled as necessary.