java - How can I compile files when my current working directory is not the default package? -


I have two files in Linux, both in default packages, AddSingleInstance.java and Finder.java

I am making an example of AddSingleInstance in Finder :

  AddSingleInstance A = New AddSingleInstance ();   

When I compile the Finder.java file, it returns the error below:

  Finder.java20: Error: can not add symbol AddSingleInstance ai = new AddSingleInstance (); ^   

I am compiling from a different directory. How do I get to compile both files successfully?

To fix your problem, your Java files should be in your classpath so that Java is detected You can manually set the classpath where you will find them:

Or :. $ Path . The easiest way to do this:

  cd javadir javac finder.java java finder   

I think most people do not face this issue ( Never before!) Because they run javac from their default package (root of their source tree).

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -