Reputation: 1570
I have a little online store. Contains two servlets, and five helper classes. I had classpath set permanently to -> servlet-api.jar. Deleted it from there, compiled the halper classes first, cannot compile the servlets cause they have reference to helper classes inside, and classpath needs to be set properly. So, could anyone show me the syntax, to point the compiler to servlet-api.jar and at the same time current directory? PS: Classes in current dir are not packaged into jar. PPS: Using Notepad and command promt, Windows7, tomcat7, java7.
Upvotes: 0
Views: 186
Reputation: 1108537
You can just specify multiple paths in the classpath using a separator which is semicolon ;
in Windows and a colon :
in *nix (Linux, Unix, Mac). To represent the current directory, use a path of .
.
Thus, all in all, this should do:
javac -cp .;/path/to/tomcat/lib/servlet-api.jar com/example/SomeServlet.java
Note, if a path contains spaces, then you should wrap the path in quotes:
javac -cp .;"C:\Program Files\Tomcat\lib\servlet-api.jar" com/example/SomeServlet.java
Upvotes: 2