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
820 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
unix in java example 9 53
Java and GPO 11 70
reverse digits of a number using for loop 5 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now