When I import a package to my MyLib class (which requires -cp to javac) I can no longer compile my MyMain class.
MyMain.java:
class MyMain
{
public static void main (String [] args)
{
MyLib.do_stuff ();
}
}
MyLib.java:
import com.google.gson.JsonElement;
class MyLib
{
public static void do_stuff ()
{
System.out.println ("Hello.");
}
}
When I javac MyLib.java I have do do it like this
javac -cp GSON_JAR_PATH MyLib.java
That works but if I
javac MyMain.java
I get
./MyLib.java:1: error: package com.google.gson does not exist
import com.google.gson.JsonElement;
but if I add -cp to the compilation command
javac -cp GSON_JAR_PATH MyMain.java
I get
MyMain.java:5: error: cannot find symbol
MyLib.do_stuff ();
^
symbol: variable MyLib
location: class MyMain
-cp .,PATHor-cp . -cp PATH.