Sending information from Java to Java script?

I am trying to send information from Java to a Java script using a JSObject, but I keep getting java.lang.ClassNotFoundException: com.sun.deploy.appcontext.AppContext exception I am using netbeans 7.1.

Here is a complete stack trace

java.lang.NoClassDefFoundError: com/sun/deploy/appcontext/AppContext at MapTest.MapApplet.init(MapApplet.java:23) at sun.applet.AppletPanel.run(AppletPanel.java:434) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.ClassNotFoundException: com.sun.deploy.appcontext.AppContext at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 3 more 

This applies to this line of code.

  win = JSObject.getWindow(this); 

All this is my import.

 import netscape.javascript.JSObject; import java.lang.*; import java.applet.*; import java.awt.Graphics; 

I really need help with this, it seems it cannot find a solution anywhere.

Thanks.

+4
source share
1 answer

I came across a similar error and was able to solve it by adding deploy.jar found in the local Java installation to the path of building the project. Not sure how to do this in netbeans, but for others using maven, you can try adding the following dependency:

 <dependency> <groupId>sun</groupId> <artifactId>deploy</artifactId> <version>7.0</version> <scope>system</scope> <systemPath>${java.home}/lib/deploy.jar</systemPath> </dependency> 
0
source

Source: https://habr.com/ru/post/1399542/


All Articles