Solved

how to include a an external jar file in a class path to to compile and run a java program?

Posted on 2007-04-05
5
823 Views
Last Modified: 2013-11-23
how to include a an external jar file in a class path to to compile and run a java program? what is the command line instruction?
0
Comment
Question by:anup001
  • 4
5 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 18860873
java - cp. yourJARFilePath yourMainClassName
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 500 total points
ID: 18860895
There are various options, like adding it to the classpath environment variable, putting the JAR to your JRE\lib\ext, or specifying it as a command line switch option. See a classpath explanation here:

http://www.experts-exchange.com/Programming/Languages/Java/Q_22450095.html#18722480

(And on the link posted at the end of that comment: http://www.mindprod.com/jgloss/classpath.html)

The switch option is also explained in detail here:

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html

and here: http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
0
 

Author Comment

by:anup001
ID: 18860973
All these instructions are for java command. I need info for the javac.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18860985
You said compile and run. I gave it for run. The links contain the same for the compile command as well:

javac -classpath JARFilePath YourFileName.java

Also explained in detail: http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18861126
>> java - cp. yourJARFilePath yourMainClassName

The . will not be there.... it came by mistake
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 84
Java Loop 6 60
Configure a Bean in an XML file 4 31
hibernate jars 4 29
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question