vendredi 15 juillet 2016

Import package from user created JAR file

I have two files; Beta.java:

package beta;
public class Beta { }

and Gamma.java:

package gamma;
import beta.*;
public class Gamma { }

I create a JAR archive using jar cvf b.jar Beta.class, yet when I try to compile with javac -cp b.jar Gamma.java I get:

Gamma.java:2: error: package beta does not exist
import beta.*;
^
1 error

I know I can just run javac *.java, but I want to be able to access Beta.class from a JAR file for portability. This is an very basic question, but I still have had a lot of trouble trying to solve it. Thanks.

Aucun commentaire:

Enregistrer un commentaire