This discussion is archived
3 Replies Latest reply: Apr 6, 2013 11:01 PM by Ayham RSS

Could not find the main class

Ayham Newbie
Currently Being Moderated
Hello All,
I face problem when i try to create JAR File.
After Creation of Jar file i tried to run it but error message
Could not find main class.

i follw this steps
1) my
import java.util.Scanner;
import edu.smu.tspell.wordnet.*;

public class WordNetOK{

    public static void main(String args[]) throws FileNotFoundException {

System.setProperty("wordnet.database.dir", "C:\\Program Files (x86)\\WordNet\\2.1\\dict\\");
WordNetDatabase database = WordNetDatabase.getFileInstance();
      String result = "";
        NounSynset nounSynset;
        NounSynset[] hyponyms;
        //creating File instance to reference text file in Java
        File text = new File("C:/javacode/WordNetin.txt");
        //Creating Scanner instnace to read File in Java
        Scanner scnr = new Scanner(text);
        //Reading each line of file using Scanner class
        int lineNumber = 1;
            String line = scnr.nextLine();
      Synset[] synsets = database.getSynsets(line);
      for (int i = 0; i < synsets.length; i++) { 
      String[] wordForms = synsets.getWordForms();
     for (int j = 0; j < wordForms.length; j++) {

//System.out.println("line " + lineNumber + " :" + line);



2) Javac

it create a class file

3) i create Manifeast.txt 
4) i run this
C:\Javacode>jar cvfm WordNetOK.jar Manifest.txt WordNetOK.class
added manifest
adding: WordNetOK.class(in = 743) (out= 435)(deflated 41%)
5) i tried to execute it as * java -jar WordNetOK.jar *

But error appear could not find main class
C:\Javacode>java -jar WordNetOK.jar
Exception in thread "main" java.lang.NoClassDefFoundError: WordNetOK
Caused by: java.lang.ClassNotFoundException: WordNetOK
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Could not find the main class: WordNetOK . Program will exit.

Note : i execute the classpath at beginning
set PATH=C:\Program Files\Java\jdk1.6.0_32\bin;
set CLASSPATH=C:\Program Files\Java\jdk1.6.0_32\bin;\javacode;
Edited by: Ayham on Apr 6, 2013 7:39 AM

Edited by: Ayham on Apr 6, 2013 7:41 AM

Edited by: Ayham on Apr 6, 2013 7:45 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        


  • Correct Answers - 10 points
  • Helpful Answers - 5 points