I have made my custom jar file and compiled it using
path C:\Program Files\Java\jdk1.7.0_04\bin;%path%
javac *.java
jar cvf QLibrary.jar *.class
Then I took that jar file and put it in the same directory where my Main.java is located
Main.java is going to use classes that are in the jar
So I have decided to put import QLibrary.*; inside Main.java
And I compile using
path C:\Program Files\Java\jdk1.7.0_04\bin;%path%
javac -cp ".;*.jar" *java
But apparently it does not recognize the library or the classes in it. What exactly am I doing wrong?
You should either list the names of all your jar files:
or you could use wildcards in this way:
Class path entries can contain the basename wildcard character
*, which is considered equivalent to specifying a list of all the files in the directory with the extension.jaror.JAR. For example, the class path entryfoo/*specifies all JAR files in the directory named foo. A classpath entry consisting simply of*expands to a list of all the jar files in the current directory.… For example, if the directory
foocontainsa.jar,b.jar, andc.jar, then the class pathfoo/*is expanded intofoo/a.jar;foo/b.jar;foo/c.jar.http://docs.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html