Hi, I have got a main class error, may i know what'swrong please?
// Driver for parser package myparser; import java.io.*; import java_cup.runtime.Symbol; import static myparser.Main.do_debug_parse; //package myparser; //import java_cup.runtime.*; class Main { static boolean do_debug_parse = true; static public void main(String[] args) throws java.io.IOException { File infile = new File("C://Users//ASUS//Documents//NetBeansProjects//myparser_proj//myparser//myparser//input.txt"); //parser parser_obj = new parser(new Yylex(fin)); FileInputStream fin = null; try { fin = new FileInputStream(infile); /* create a parsing object */ parser parser_obj = new parser(new Yylex(fin)); Symbol parse_tree = null; if (do_debug_parse) parse_tree = parser_obj.debug_parse(); else parse_tree = parser_obj.parse(); System.out.println("Parse successful"); fin.close(); } catch(FileNotFoundException e) { System.out.println("File " + infile.getAbsolutePath() + " could not be found on filesystem"); } catch(IOException ioe) { System.out.println("Exception while reading the file" + ioe); } catch (Exception e) { /* do cleanup here -- possibly rethrow e */ } finally { /* do close out here */ } } }
The code compiles fine but the error message is received when the code is run.
The errors are:
Exception in thread "main" java.lang.NoClassDefFoundError: myparser/Yylex (wrong name: Yylex)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :791)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:449)
at java.net.URLClassLoader.access$100(URLClassLoader. java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
at myparser.Main.main(Main.java:27)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)