0

i have created jar file when i am double click jar file i got error could not find main class program will exit

i am setting jar properties file mycomputer->tools->folderoptions->filetypes->jdk->javaw

i have created manifest file also i am using windows xp operating system

can anybody tell wha t is the problem?

thanks in advance

Edited by peter_budo: Do not use CODE SNIPPED for asking questions. Use FORUM HREAD!

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
0

i have created jar file when i am double click jar file i got error could not find main class program will exit

i am setting jar properties file mycomputer->tools->folderoptions->filetypes->jdk->javaw

i have created manifest file also i am using windows xp operating system

can anybody tell wha t is the problem?

thanks in advance

The problem you state shows that the system can not find the main class. Either you have specified a wrong location in the main class or you or not using the correct command to create jar file. I will suggest to use an IDE like NetBeans since they can easily create a jar file for you. If you are using a manifest file then remeber that you need to use new line after the name of main class.

0

Take a look,

here is a Test.java

package pk;
public class Test{
 public static void main(String[] args){
       System.out.println("Hi");      
  }
}

Now compile Test.java,

>javac Test.java -d .

Note:
-d switch creates a package folder at . (working directory).

Create a manifest file called mf and put Main-Class entry into it.

Main-Class: pk.Test

Create .jar file

>jar -cvfm  sample.jar mf pk
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.