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
834 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

622 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