SDN Featured Content

Do you Think Hibernate is better technology that EJB

Java/J2EE blogs

Welcome to my java /J2EE blogs.


Saturday, January 23, 2010

Compiling Java class from command Line setting classpath in core java

Hi All,

This is simple problem we guys face while compiling the java class when we need to specify the jar files into the path and compiler become awsome and throws the hell lots of errors. Don't worry .. java is not so bad. The only thing is that here we have to compile and run without an IDE(IDE came after the compilers).

Follow the below line to compile the java classes.

javac -classpath "path of the jar files like(lib\jar1.jar;lib\jar2.jar)" JavaClass.java


Here path of the jar files is relative to the folder where the java class resides.

But here I have missed one thing and due to that I'll get the errors when the same compiled file will get run from the command line as



java -classpath "path of the jar files like(lib\jar1.jar;lib\jar2.jar)" JavaClass


Friends make sure that your classpath is like ".;lib\jar1.jar;lib\jar2.jar"

Atleast when you are running java command.

You will now be able to compile and run your code successfully.