2

I am trying to use an applet that is located in a jar that is located somewhere else in my system (not in the same project location as the web stuff). I know of a property called codebase which is pointing to where the web for look for the jar that has the applet class. This is the code that I put in, but can't get it to work...

<script type="text/javascript">  
        if (_app == "Netscape") 
        {
            document.write('<object classid="java:UareUApplet.class"',
               'type="application/x-java-applet"',
               'name="UareUApplet"',
               'width="1"',
               'height="0"', 
               'type="application/x-java-applet"',
               'pluginspage="http://java.sun.com/javase/downloads"',
               'archive="UareUApplet.jar, dpuareu.jar"',
               'onFMDAcquiredScript="onFMDHandler"',
               'onEnrollmentFailureScript="onEnrollmentFailureHandler"',
               'onImageCapturedScript="onCaptureHandler"',
               'codebase="C:\Users\modonnell\Desktop\UareUApplet\UareUApplet\UareUApplet\Register\"',
               'onDisconnectedScript="onDisconnectedHandler"',
               'onConnectedScript="onConnectedHandler"',
               'onErrorScript="onErrorHandler"',
               'onLoadScript="onLoadHandler"',
               'bRegistrationMode="true"',
               'bDebug="true"',
               'bExclusivePriority="true"',
               'scriptable="true"',
               'mayscript="true"',
               'separate_jvm="true"> </object>'); 

}

If I paste in the jar into the folder of my web project, and take away the "codebase" declaration, the applet will work. But I don't want to have to paste in the jar after each compile.

Scott
  • 174
  • 5
  • 19
  • 2
    Use [`deployJava.js`](http://download.oracle.com/javase/7/docs/technotes/guides/jweb/deployment_advice.html) to write the applet element as needed for the browser. – Andrew Thompson Mar 13 '13 at 02:47
  • `'codebase="C:\Users\modonnell\Desktop\UareUApplet\UareUApplet\UareUApplet\Register\"'` 2 notes: 1) That is a String the represents a file path./name rather than the URL that points to the file. It would be more along the lines of `'codebase="file:///C:/Users/modonnell/Desktop/UareUApplet/UareUApplet/UareUApplet/Register/"'` 2) That path would, as understood by the JVM, point to a path on the drives of a (Windows based) PC of the end user. Unless all these machines are controlled by you and make that path available, it will fail. **Why *not* put those resource onto the server?** – Andrew Thompson Mar 13 '13 at 03:06
  • Ok, thank you. I tried this, but it still did not work. I suppose putting the resource onto the server is fine. I added the jar to the server (this is a different jar that I trying out), but now this is not working also. I think this may be a problem because my jar has subfolders that contain the classes – Scott Mar 13 '13 at 15:19
  • *"I tried this.."* Which part of 'this'? `deployJava.js` or the codebase? IF the latter, did you check the URL or take what I just made up? Provide a lot more details and edit them into the question. – Andrew Thompson Mar 14 '13 at 00:45
  • I'm sorry for not specifying, I tried using codebase with the file:/// appending to the beginning. I still used the correct path from my system though. I just created a new jar with the classes right at the root. When I do very basic inject of the applet into an html page it works. I just tried putting it into my big web application though, and it is coming up with a classnotfound exception. I even put the jar files in the same file path as the jsp that is calling it – Scott Mar 14 '13 at 20:53
  • Show me the HTML used for the big web application. Are you using `deployJava.js` as suggested in my first comment? (Tip, if you are ignoring my suggestions, I'll ignore your question.) – Andrew Thompson Mar 16 '13 at 01:29

1 Answers1

0

I needed to add the path to the jar all in the archive tag. I needed to completely remove the codebase tag.

Scott
  • 174
  • 5
  • 19