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

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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.