Solved

main class not found when launching jar

Posted on 2004-08-11
9
245 Views
Last Modified: 2012-06-22
I ran into a strange problem while trying to deliever a java application. I stored all my application into a jar and added a correct manifest file (created with eclipse). When I try to start the application with a double click everything works fine on my system, the application is launched as expected. The problem is when I copy the jar file ( it is really exactly the same jar) to another system and try to launch it with a double click I get the error: "Could not find the main class. Program will exit.". The file type jar is associated with javaw and java is properly installed on both systems. Has anybody an idea why the same jar file migth launch on one system but fail to find the main class on another???
0
Comment
Question by:schmida
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11774777
I've seen this happen before. What happens when you do

java -jar yourjar.jar

at the command line?
0
 
LVL 1

Author Comment

by:schmida
ID: 11774918
I tried it and found out that
java -jar myjar.jar
works on both systems.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11774965
I don't know the reason for the problem, but a good workaround is to use precisely that command as the command for a shortcut. You can even use your own icon ;-)
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:schmida
ID: 11775294
Ok I fixed the problem. The problem was that the jarfile was launched with javaw - jar on one system and only with javaw on the other. When java is installed it puts a registry key name jarfile into HKEY_CLASSES_ROOT which specifies that jar files have to be opened with the command javaw -jar. The ending .jar (also in HKEY_CLASSES_ROOT) is then associated with the jarfile entry. When Winrar is installed on the system it chnges the association of .jar with jarfile to WinRAR. If try to associate jar files with javaw again the files are only open with javaw. To fix the problem the value of the .jar entry in HKEY_CLASSES_ROOT has to be reset to jarfile. Thanx for trying to help me CEHJ anyway. I ll ask to refund the points.
0
 
LVL 1

Expert Comment

by:quddhus
ID: 11775327
make sure that the manifest file has this entry :- also make sure java bin folder is in PATH.

Manifest-Version: 1.0
Created-By: ABC
Main-Class: MyMainclass
0
 
LVL 1

Author Comment

by:schmida
ID: 11775390
thanks quddhus but everything was fine with my manifest the problem was with file associations.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11775495
>>When Winrar is installed on the system it chnges the association of .jar with jarfile to WinRAR.

That's the kind of bad behaviour you don't need ;-)

>>I ll ask to refund the points.

That's OK.
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 11811613
Closed, 500 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Moderator
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question