• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jar Problem

 
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a jar file with this command :

D:\jar\FinalSchool>jar cmf0 Manifest.txt SchoolFinal2.jar *
Where,
D:\jar\FinalSchool is the directory where class files package, and manifest file exists.

After this command a jar is created in FinalSchool package. If i run the jar by double-clicking it, it runs fine. But, if i copy this created jar to another location, it doesn't works.

It shows the following exception :



But, i have included the jcalendar-1.4. And this program works fine when located in the place where it was created
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After little bit research i found that, when placing all required jars with the jar created in a separate folder, it works.
Now my Question is that, since the created jar contains the required jars, why , again i need to place the required jars with this application jar? And what is the solution for this?

Here is my manifest file :
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No reply yet

Please reply Ranchers
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kunal Lakhani wrote:After little bit research i found that, when placing all required jars with the jar created in a separate folder, it works.
Now my Question is that, since the created jar contains the required jars, why , again i need to place the required jars with this application jar? And what is the solution for this?

Here is my manifest file :



Here, the problem is of classpath.
You are having JARs inside a JAR. So, if you give classpath as '.', JVM will search for classes inside the Jar File (But not inside the JARs inside that JAR)..

If A.jar contains A.class and B.jar
and B.jar contains B.class
Then, with classpath set to '.', and running the A.jar, JVM will be able to find A.class, but not B.class which is inside B.jar

I have found the problem for you, and you have to find the Solution. If you sort out this problem, you are done.

Hint: - You need to use Custom Class Loader (JarClassLoader in this case).. There are other ways also..
For more help, you can use this link.
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply R. Jain. That was a wonderful information. I am looking forward to use Custom Class Loader. Will post the updates here
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After googling i found a solution, that if i create an .exe file and package all required jar files, this problem doesn't occurs. Any negative point with this?
reply
    Bookmark Topic Watch Topic
  • New Topic