Skip to main content

java.lang.NoClassDefFoundError: net/java/javafx/jsr223/JavaFXScriptEngine

3 replies [Last post]
asdf_asdf
Offline
Joined: 2008-07-03
Points: 0

His,

trying to compile a java class that should instantiate a javafx object under eclipse with javafx plugin. and got the following error:

[java] Exception in thread "main" java.lang.NoClassDefFoundError: net/java/javafx/jsr223/JavaFXScriptEngine
[java] at de.netzprofis.gs.stock.client.StockClientCode.main(StockClientCode.java:55)
[java] Caused by: java.lang.ClassNotFoundException: net.java.javafx.jsr223.JavaFXScriptEngine
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

here is the class code:
import javax.script.ScriptEngineManager;

import net.java.javafx.jsr223.JavaFXScriptEngine;

public class SCode {

public static void main(String args[]) throws InterruptedException {
ScriptEngineManager manager = new ScriptEngineManager();
JavaFXScriptEngine fxEngine = (JavaFXScriptEngine) manager
.getEngineByName("javafx");

try {

Object o = fxEngine.eval("JavaFXTable");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

if anyone could suggest a solution?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

You need to use JDK 1.6 or add Java Scripting libraries into the project classpath:
https://scripting.dev.java.net/servlets/ProjectDocumentList

asdf_asdf
Offline
Joined: 2008-07-03
Points: 0

thanks,

but i already switched to jdk 1.6 since Eclipse had been underlining the ScriptEngineManager class name as unrecognized. Why does it work then?

I actually use an external ant file (maybe that's the cause) to compile and rund the project. Have added the following libraries




to the classpath. Is that the right way?

asdf_asdf
Offline
Joined: 2008-07-03
Points: 0

resolved, thank you.

should have not had "/" before lib.