JavaMail Problem
Hi all,
I wrote a program which uses the javamail with mail.jar and activation.jar .
I have no trouble with my computer, but other computers do not open the jar file with the "Could not find the main class.Program will exit" error message. So that, i wanted to include javamail's jar files in the my jar file. So,
My main class's name is Gmail and my jar file includes the followings:
Gmail.class
mail.jar
activation.jar
META_INF (directory) --> has MANIFEST.MF
My manifest file has the followig lines:
Manifest-Version: 1.0
Main-Class: Gmail
Class-Path: mail.jar activation.jar
I will be very thankful if you can help me to solve the problem.
Thanks.
[738 byte] By [
yasin1499a] at [2007-11-27 11:33:28]

# 1
You have to put mail.jar and activation.jar in the same directory as your jar file(Gmail.jar I presume).
Note : The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.
See http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
# 2
Thanks for reply.
Now my jar files outside but old jar file doesn't run it. I must build the jar file again. In eclipse i couldn't achieve to build with my jar file which uses external jar files(mail.jar and activation.jar). Then, i tried netbeans, but it has a regional language problems, so it doesn't run correctly.
And finally i tried to build my jar in command line. But it sends an arror message "Exception in thread 'main' java.lang.NoClassDefFoundError".
My commands were;
java -cp Gmail.jar Gmail
and
java -cp Gmail.jar mymail.Gmail
(mymail is the package name and Gmail is the class name)
I am trying to run my program in any computer for 4 days. I can go mad. Please help me.
# 5
>To run the program,the user should double click the my jar file.
Yes, the user should have java correctly configured.
See http://java.sun.com/javase/6/webnotes/install/jdk/install-windows.html Paragraph 4
# 7
>But isn't it a bad way for programming?
Absolutely not. Every one who needs java to run correctly on his/her machine must configure it properly. (Applets, executable jars, ...)
# 8
Ok. Thank you for your care java_2006.
I overcame it. The problem was not about jar files. I had a mistake in the program flow. And i located the jar files as you told me in your first message. So there necessity to configure the java for users.
Thanks a lot.