• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using jar files

 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm sorry for this basic question....
I built a jar file , and now I want to add it to another java project.
I'm using Eclipse. I added that jar to the project and added it to the class path.
How can I call it's methods from my new class in the new project ?
Thanks.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply import the classes you intend to use in the .jar.

When you are not using Eclipse, you will have to use the -cp options for the java tool, or add the classpath to the manifest file in a new jar file.
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I added to the folder of my project the file hasp.jar.
I added it to the class path (with eclipse)
I write import hasp and it does nothing.
Even my jar's main class name doesn't work.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing more about how you're doing this it'll be hard to help.

If the library is included in the project's path then importing a class and using it will work fine: could you include the relevant portions of source (the import, how you're trying to use the import) and the specific error you get?
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I added again the jar to the classpath and now it looks fine.
I don't know what is different...
Thanks anyways.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic