Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

how to import an API not in jdk ?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22575
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Specify the library in the class path. http://faq.javaranch.com/java/HowToSetTheClasspath
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 74727
336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 74727
336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did it work? Have you had any success?
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic