• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call another class when there is no source code?

 
irshad ahmed
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my main program A.java, I need to call another class (B) which is in a .jar file. But I don't have the source code for B.
How do I get A to compile? (What should the import look like?)
Thanks,
Irshad
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing special about the import. In fact, most of the standard Java API classes are found in a jar file. The main difference with a third-party jar file is that you need to add it to the CLASSPATH variable. You can either do this directly to the environment variable, which will cause the jar file to be searched for all Java programs you write, or you can use the command line options for javac. If you don't plan on using the jar file for other projects, I would suggest the later.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic