SeanLetendre SeanLetendre - 3 months ago 20
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 LMatrix.java


in Windows PowerShell, the stack trace reads:

LMatrix.java:70: 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?

EJP EJP
Answer
C:\programming\java\javaprojects\com\kavricious\lmath> javac LMatrix.java

That should be

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

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.