| Author |
Classpath for new package
|
Kay Kumar
Greenhorn
Joined: Feb 28, 2005
Posts: 11
|
|
Hi there, I am a complete begginer so hold back the abuse for now I have downloaded a new package called javabook. I am using a new text book (author = Wu), in which they use a package that i need to download. My classpath is .;C:\j2sdk1.4.2_04\lib\tools.jar Where do i put the javabook package so that i can use it in my programs. Thanks Kap
|
 |
Lionel Badiou
Ranch Hand
Joined: Jan 06, 2005
Posts: 140
|
|
Hello Kay,
Where do i put the javabook package so that i can use it in my programs.
Just put your jar in your classpath The simplest way to set up the classpath is : javac -classpath /mypackagename/javabook.jar ... Note that javac required that your jar must be in /mypackagename directory. You may take a look at this article to quickly understand how classpath works. Hope that helps,
|
Lionel Badiou
CodeFutures Software
|
 |
Kay Kumar
Greenhorn
Joined: Feb 28, 2005
Posts: 11
|
|
posted February 28, 2005 05:04 AM -------------------------------------------------------------------------------- Hi there, I am a complete begginer so hold back the abuse for now I have downloaded a new package called javabook. I am using a new text book (author = Wu), in which they use a package that i need to download. My classpath is .;C:\j2sdk1.4.2_04\lib\tools.jar Where do i put the javabook package so that i can use it in my programs. Thanks Kap -------------------------------------------------------------------------------- Posts: 1 | Registered: Feb 2005 | IP: Logged Lionel Badiou ranch hand Member # 89965 posted February 28, 2005 05:24 AM -------------------------------------------------------------------------------- Hello Kay, quote: -------------------------------------------------------------------------------- Where do i put the javabook package so that i can use it in my programs. -------------------------------------------------------------------------------- Just put your jar in your classpath The simplest way to set up the classpath is : javac -classpath /mypackagename/javabook.jar ... Note that javac required that your jar must be in /mypackagename directory. You may take a look at this article to quickly understand how classpath works. Hope that helps, -------------------- Rite So do i add another classpath which is .;C:\j2sdk1.4.2_04\javabook.jar Is that rite? Or, would i just add as below .;C:\j2sdk1.4.2_04\lib\javabook.jar Sorry if being very thick
|
 |
Lionel Badiou
Ranch Hand
Joined: Jan 06, 2005
Posts: 140
|
|
Hello Kay, You have two ways to set up a classpath : 1 - Specify classpath to the javac compiler (through the -classpath option) 2 - Set classpath at system level (that implies to modify an environnement variable of your operating system). This is the variable you mentionned in your posts. I suggest you to use the first method this way : javac -classpath %CLASSPATH%;pathToMylibs\javabook.jar pathToMyCode\myCode.java (assuming windows os) This command line compiles myCode.java and sets the classpath to the system classpath + javabook.jar (a .jar file should be considered as a directory). Doing this, myCode.java may use javabook.jar methods. Check out this article for details. Hope that helps,
|
 |
Kay Kumar
Greenhorn
Joined: Feb 28, 2005
Posts: 11
|
|
Thanks I'l give it a go. If i get stuck il give you a shout. Thanks again
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
You may also want to take a look at "How to Set the CLASSPATH" in our FAQ. Layne
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: Classpath for new package
|
|
|