最近在搞JavaCC,也一直跟着Eclipse 3.6的测试版不断更新Eclipse。遇到如下问题:
现象:
JavaCC Eclipse Plugin中的JavaCC Console中显示:
>java -classpath D:/software/Develop/IDE/eclipse3.6RC1/plugins/sf.eclipse.javacc_1.5.22/javacc.jar javacc PlSql.jj Error: Could not find main class javacc java.lang.NoClassDefFoundError: javacc at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:198) Caused by: java.lang.ClassNotFoundException: javacc at java.net.URLClassLoader$1.run(URLClassLoader.java:299) at java.net.URLClassLoader$1.run(URLClassLoader.java:288) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:287) at java.lang.ClassLoader.loadClass(ClassLoader.java:422) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325) at java.lang.ClassLoader.loadClass(ClassLoader.java:355) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:195) Exception in thread "main"
解决方案:
到workspace的项目根目录下,打开.settings/sf.eclipse.javacc.prefs,修改RUNTIME_JJJAR和RUNTIME_JTBJAR两个属性的值,设置为正确的路径即可。
说明:
JavaCC Eclipse Plugin把命令行的classpath路径设置到了项目路径中,更改eclipse目录的话,路径不会自动更新,还是会指向老的目录,在.setting里存在和本地环境有关的属性是一个不好的设计。