This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to import an API not in jdk ?

 
chintan chainani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hye greenhorns, am using java 1.6 on windows xp home.
I am running programs in main for which i want to use an API which is not a part of the jdk, i have tried placing the jar file of this API (which somebody gave me to use for the console io) in the lib folder of jdk, but on compiling gives error, it says path not found for that API.
Can somebody please help me figure it out , how should i import this class into the main program.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specify the library in the class path. http://faq.javaranch.com/java/HowToSetTheClasspath
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set the classpath to do this. We have a useful FAQ entry that will help.
 
chintan chainani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks guys, i did go through the 'set the Classpath ', but i need more help, am bit of a novice on this,
now, a PATH has already been defined by me in user variable for home of the Environment variable settings which shows the directory where my JDK lies, i understand this is necessary for java to compile and run from another directory. Do i now need to add the location of of this package am using called ncst.pgdst.* , to a new user variable called CLASSPATH, cause i did that and again when i compile a program containing that package it gives an error saying 'package ncst.pgdst does not exist.'

! What to do
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can remember you use the -cp option when you call java (and probably javac too). The technical notes are here and here. Those instructions are specifically for Windows, not Linux.

Try javac -cp .;C:\myFolder\MySubFolder\ncst.pgdst.jar

I can't remember whether you write .jar at the end or not. Try with and without.
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did it work? Have you had any success?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic