Compile and Run Java Class With External Jar Using Console

13 Apr


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.


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


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: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: