RSS

Compile and Run Java Class With External Jar Using Console

13 Apr

Preparation

In this example I use mysql-connector-java-5.1.6.jar for external library. I already set my Java classpath on windows environment variables. My java main class is QueryManager.class and need one argument placed under controller package. Important to know, you must place your main class under a package, cause it’s important for JVM to know where to start search your class.

Compile

javac -classpath mysql-connector-java-5.1.6.jar; controller/*.java
javac -classpath mysql-connector-java-5.1.6.jar: controller/*.java

Run

java -classpath mysql-connector-java-5.1.6.jar; controller.QueryManager "TRUE"
java -classpath mysql-connector-java-5.1.6.jar: controller.QueryManager "TRUE"
 
Leave a comment

Posted by on April 13, 2013 in Education

 

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: