Could not find Main class.Program will exit

Hello everybody,

I'm trying to export Jar file from a working Java app (in Eclipse).

As you can read in the post's title, opening my created Jar, Windows XP returns me a popup saying "Could not find Main class.Program will exit"

So, i looked through forums and through google to find the solution, but I tried almost everything and nothing seems to work.

1)Manifest file is builded with the declared Main class

2)No compile errors or warnings appears during export

3)The application works perfectly through ecplise also as SWT application

The only suspect thing I found is this one:

trying to call this command

java -jar JavaCommesse.jar

Compiler returns me

Exception in thread main java.lang.NoClassDefFoundError:ca/ansir/swing/calendar/calendarfield

Thisca/ansir/swing/calendar/calendarfield is a library I use from Ansir software to call a little Calendar popup.

Maybe is this the problem? How to solve it?

please help!

[1037 byte] By [Pentolinoa] at [2007-11-27 8:50:36]
# 1

Seems like you have an external jar (ca/ansir/swing/calendar/calendarfield) that you use on your main class, but you dont have this external jar in your jar... so when java tries to get the class referenced on the external jar cant find it...

Include the external jar in your jar and/or make the external jar reachable on the classpath of your jar.

Xtremebcna at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 2

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 3

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 4

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 5

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 6

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 7

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 8

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 9

Thanks for your reply :D

The strange thing is that this .jar is declared into the .classpath just like other libraries that does not throws this Exception.

This jar's path is correctly described into the .classpath (considering that Eclipse is able to retrieve this jar and let me run the application with his own Run function)

any ideas?

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 10
Sorry my browser went crazy and told me it sends nothing.. now I discover that it have sent many postssorry...and I'm waiting for your replies too ;)
pentolinioa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 11
You have defined the classpath in Eclipse project but not on your sources, the IDE classpath is not saved in your jar.
Xtremebcna at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 12

IDE classpath?

What do you mean?

this is my classpath file

<?xml version="1.0" encoding="UTF-8"?>

<classpath>

<classpathentry kind="src" path=""/>

<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

<classpathentry exported="true" kind="lib" path="C:/Programmi/xampp/tomcat/common/lib/mysql-connector-java-5.0.5-bin.jar"/>

<classpathentry exported="true" kind="lib" path="C:/Programmi/xampp/tomcat/common/lib/ansir_list.jar"/>

<classpathentry exported="true" kind="lib" path="C:/Programmi/xampp/tomcat/common/lib/jdom.jar"/>

<classpathentry exported="true" kind="lib" path="C:/Programmi/xampp/tomcat/common/lib/ansir_calendar.jar"/>

<classpathentry kind="output" path=""/>

</classpath>

As you can see it points to the same directory for all the jars.

ansir_calendar.jar is the problematic one..

any other ideas?

pentolinioa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 13
This classpath is what Eclipse uses to register where external jars are.. but this info is not on your generated jar seems ...
Xtremebcna at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 14

You say this classpath is what Eclipse use to register where external jars are (I assume you think that compiler and Eclipse doesn't point to the same "jar schema") but I have some questions related to this point:

1)this is my first desktop app, until this day I developed something for Tomcat and .classpath file was the file referencied from tomcat to know where libraries were

2)Why compiler is able to retrieve the other jar and not that specific one?

3)How, in your opinion, I can solve this situation? I have an application waiting to be deployed and it's hagend up for this issue.

Please help me fix it!

Thanks for your replies!

Pentolinoa at 2007-7-12 21:02:04 > top of Java-index,Desktop,Deploying...
# 15
try to set the classpath (Class-Path) in the manifest file itself.once u set the classpath inside the manifest file, it is independent of classpath in IDE.--Subbu
Subbu_javaa at 2007-7-21 22:48:43 > top of Java-index,Desktop,Deploying...
# 16
im having the same problem but its with worlscape.rar its a moparscape client i click the client and it sais could not find main class program will exit
fer_realza at 2007-7-21 22:48:43 > top of Java-index,Desktop,Deploying...
# 17
Try using FatJar. I wrestled with the JAR tool in eclipse for way to long and gave this a try. Worked the first time and now I dont use anything else. http://fjep.sourceforge.net/
ElCida at 2007-7-21 22:48:43 > top of Java-index,Desktop,Deploying...
# 18

Hello,

As discussed in our personal emails, this problem has been solved.

For others benefit the problem, in this case, was not the class path. In this case the jar had mixed class names and when unpacked on a windows computer and repackaged there were classes that were lost. The solution was to either use the jar in the class path as it was or for Ansir Development to create a new build using the dontusemixedcaseclassnames proguard option.

The new build is now available here:

http://www.ansir.ca/downloads.jsp

For anyone that is interested this is a very nice full featured calendar popup with one of the smallest footprints that you will find. If you haven't given it a try, then please do so. Your comments are always appreciated too, so if there are some suggestions or features that would like to see implemented then please let us know.

Cheers,

Dan Andrews

dan.andrewsa at 2007-7-21 22:48:43 > top of Java-index,Desktop,Deploying...
# 19
@ dan.andrews: I have the same problem when I use another product of ansir, the "Auto-Complete Text Field". Can you tell me clearer, how can I solve this problem. I also downloaded the newest files on the web. Cheers,Quang Le
eleanhqa at 2007-7-21 22:48:43 > top of Java-index,Desktop,Deploying...