Broken applet - assist please

Fixed now, thanks. :slight_smile:

This applet is broken, I get an InvocationTargetException. As far as I know these generally come up when something unrelated is wrong. Running this as an app or in my local applet loader works fine. For some reason, my console is empty so I can’t get a stack trace.

Could someone please try running this and post the stack trace they get? Thanks very much.

This is the error I get:


java.lang.reflect.InvocationTargetException
	at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission sun.java2d.opengl write)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at java.lang.System.setProperty(Unknown Source)
	at com.otcsw.darwinsapple.Globals.initialize(Globals.java:65)
	at com.otcsw.darwinsapple.DarwinsAppleController.initialize(DarwinsAppleController.java:36)
	at com.otcsw.darwinsapple.DarwinsAppleMain.<init>(DarwinsAppleMain.java:34)
	at com.otcsw.darwinsapple.DarwinsAppleMain.<init>(DarwinsAppleMain.java:23)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$000(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.awt.EventQueue$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception : java.lang.reflect.InvocationTargetException

It seems that you did not sign your jar correctly… (I think ::slight_smile: )

Ah, I think I asked for hardware acceleration and maybe I’m not allowed to get it? The JAR works completely within the sandbox, shouldn’t need to be signed. Thanks for the stack trace, I’ll have a look later.

How are you requesting it? Shouldn’t system properties be specified in a tag (doesn’t seem to be looking at your page source)? According to the deployment guidelines that property shouldn’t cause the need for signing.

IANAAS (I am not an applet specialist) :wink:

I was getting very bad performance drawing some images so I tried turning on hardware acceleration using both launch params and this code I found on the internets:


System.setProperty("sun.java2d.opengl","True");

Turning it on seemed to do nothing whatsoever, so I sigh had to make my code not shitty instead. I removed that line of code, looks hunky dory now. Amusingly enough it won’t grab focus so keyboard input won’t work. New problems, go! I’ll fix that when I get some time.

[EDIT]I fixed the focus issue. I was already calling requestFocusInWindow() but interestingly enough it performs slightly differently in an applet than it does in an app. It must be called later (after the applet is already loaded and added to screen). I added in a popup that appears if you don’t have focus, works well enough.[/EDIT]

It is working perfectly fine for me, no exceptions and good speed :slight_smile:

Sorry I see only a black screen.

Setting sun.* properties in Java is not allowed for applets. To do so, you have to set them as parameters in the html file:


<applet ..... >
    <param name="java_arguments" value="-Dsun.java2d.opengl=true" />
    ....
</applet>

Works for me (Windows 7) as well.

this one works for me, in index.html file:

<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width="100%"
      height="100%"
      archive="jar/applet-launcher.jar,
               jar/gluegen-rt.jar,
               jar/jogl.all.jar,
               jar/<your_file>.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" value="main.class.here">
   <param name="subapplet.displayname" value="">
   <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="1">
   <param name="jnlpExtension1"
          value="jar/jogl-all-awt.jnlp">
   <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
   <param name="jnlp_href" value="jar/applet-launcher.jnlp">
</applet>

applet-launcher.jnlp:

<?xml version="1.0" encoding="utf-8"?>
<jnlp href="applet-launcher.jnlp">
  <information>
    <title></title>
    <vendor></vendor>
    <homepage href=""/>
    <description></description>
    <description kind="short"></description>
    <offline-allowed/>
  </information>

    <resources>
      <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      <property name="sun.java2d.noddraw" value="true"/>
      <jar href="yourfile.jar" main="true"/>
      <extension name="newt-all-awt" href="jogl-all-awt.jnlp" />
    </resources>

  <applet-desc 
      name="Applet"
      main-class="main/class.here"
      width="640" 
      height="480">
  </applet-desc>
</jnlp>

Ayup, I had that on as well and it didn’t seem to do anything so I turned it off. I forgot I still had it being set in code. I was trying both to attempt to get any sort of difference.