Embedding Java applet in html5 - java

I'm trying to embed a Java applet that I just made into an HTML 5 compliant page. I'm using the following tag to embed the .jar file:
<object type="application/x-java-applet" height="300" width="550">
<param name="code" value="MainClassName" />
<param name="archive" value="MyJarFileName.jar" />
Applet failed to run. No Java plug-in was found.
</object>
The java applet will try to run but stop with:
java.lang.reflect.InvocationTargetException
I'm having trouble finding what is the cause of this error. My .jar file will run fine on its own. The main class extends JApplet, which contains a frame, which contains a JPanel.
What is causing this error?

Related

Cordova: Add native code without plugins in config.xml

How can I add android native code to a Cordova based project without creating a plugin? what are the entries to put in config.xml?
I'm asking because I have native code that I want to add which is specific to my project and I don't want to always have to remove and re-add the plugin, it will also make svn cycles more complicated.
Is it even possible?
The only part in config.xml that I see that might be related are-
<feature name="NiceNativeFeature">
<param name="android-package" value="com.mycomp.plugins.YourClass"/>
<param name="onload" value="true" />
</feature>
Thanks.

Same DLL accessed by two applets in 2 web applications

I need a suggestion to solve the following problem.
I have two web applications (let's say WEBAPP-A and WEBAPP-B) running under the same application server. Each login page in each application page activates a specific applet
(let's call them JAPP-A and JAPP-B, respectively). These two applets need to use the same DLL.
Each applet (JAPP-A or JAPP-B) works OK when accessing the application separately (in our case the browser used is Internet Explorer 8.0 and the JRE version of the client is 1.7.0_45). However, when redirecting from WEBAPP-A to WEBAPP-B, the applet JAPP-B crashes.
I get the error:
UnsatisfiedLinkError: 'DLL already loaded in another classloader'
So I have tried to use the same classloader for JAPP-A and JAPP-B by setting the same CODEBASE value inside the applet tag and deploying the JAR containing the JAPP-B code under the CODEBASE path, but we got the same error message.
Can anyone suggest an alternative approach in order to get the applet JAPP-B working correctly?
Deploy each applet in it's own Java Virtual Machine. E.G. from Applet Deployment Parameters: separate_jvm.
<APPLET archive="my_applet.jar" code="MyApplet" width="300" height="300">
<PARAM name="java_arguments" value="...">
<!-- use a separate JVM for this applet! -->
<PARAM name="separate_jvm" value="true">
</APPLET>

HTML Java applet integration

I know this has been asked multiple times already, and I have already tried to use all of the solutions that I could find, but I wasn't able to get any success. I have a JApplet that works successfully (I've pasted the heirarchy below, as I don't think the code itself is relevant to the issue. I might be wrong). I also have some basic HTML code that seems to be correct based on the solutions that I have found. The problem is that I continue to get the same error:
(source: gyazo.com)
And I'm not sure why I'm getting it. Is it because everything in the heirarchy is a .java file?
my HTML file:
<html>
<head></head>
<body>
<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class"></applet>
</body>
</html>
Hierarchy:
Files:
Any help would be appreciated. Thanks so much!
Can you try..
<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class">
First, you need to close you <head> tag with </head> and do the same with the <body> tag.
Also, the <applet> tag has been deprecated in HTML4.01 and is not allowed in HTML5, so you should replace for <object> tag
So, if you are using it on Chrome, for instance. It will NOT work.
If your applet is in the same dir. as the html file you don't need to specify it as the browser searches for a location of the document in the same dir, if you have it elsewhere then it's ok to have the archive which should containt the path to the jar file.
Beside that you should consider adding to the code attribute also the package in which your class resideds, all separated by a dot code="OneQuestMapgen.OneQuestMapgen.class"
Shouldn't your html be like this?
<html>
<head></head> <!-- closing the head before the body -->
<body>
<applet width="950" height="600" code="OneQuestMapgen.OneQuestMapgen.class"
type="application/x-java-applet;jpi-version=6"
archive="test.jar">
</body>
</html>
in html5 it should be something like
<object type="application/x-java-applet" height="600" width="950">
<param name="code" value="OneQuestMapgen.OneQuestMapgen.class" />
<param name="archive" value="test.jar" />
Applet failed to run. No Java plug-in was found.
</object>

Java applet cached forever, not downloading new version?

We have a case where clients seem to be eternally caching versions of applets. We're making use of the <param name="cache_version"> tag correctly within our <object> tag, or so we think. We went from a version string of 7.1.0.40 to 7.1.0.42 and this triggered a download for only about half of our clients.
It doesn't seem to matter which version of the JRE the client is running. We've seen people have this problem on 1.4, 1.5 and 1.6.
Does anybody have experience with explicit cache versions? Does it work more reliably (ignoring speed) to instead rely on the cache_archive's "Last-Modified" and/or "Content-Length" values (as per Sun's Site)?
FYI, object block looks like this:
<object>
<param name="ARCHIVE" value="foo.jar">
<param name="CODE" value="com.foo.class">
<param name="CODEBASE" value=".">
<param name="cache_archive" value="foo.jar">
<param name="cache_version" value="7.1.0.40">
<param name="NAME" value="FooApplet">
<param name="type" value="application/x-java-applet;jpi-version=1.4.2_13">
<param name="scriptable" value="true">
<param name="progressbar" value="true"/>
<param name="boxmessage" value="Loading Web Worksheet Applet..."/>
</object>
Unfortunately, different versions of the Java Plug-In have different caching behaviors. Setting your Cache-Control and Last-Modified HTTP headers is the ideal solution, but it only works under the most recent versions of the JRE.
The only solution GUARANTEED to work is to rename your application jars when their versions change (we've seen strange caching behavior when trying other tricks like adding query strings based on file dates). This isn't so difficult to do if you have a properly automated deployment system.
You can remove applet from Java cache using Java Control Panel.
For example, on Win XP
Start -> Control Panel -> Java -> Temporary Internet Files[View]
As per this link
, same jar file should not be listed int "archive" and "cache_archive" params. In that case, the JAR file is cached using the native browser cache.

Java: JApplet, How do you embed it in a webpage?

I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead.
How do you embed a JApplet in HTML on a webpage?
Here is an example from sun's website:
<applet code="TumbleItem.class"
codebase="examples/"
archive="tumbleClasses.jar, tumbleImages.jar"
width="600" height="95">
<param name="maxwidth" value="120">
<param name="nimgs" value="17">
<param name="offset" value="-57">
<param name="img" value="images/tumble">
Your browser is completely ignoring the <APPLET> tag!
</applet>
Although you didn't say so, just in case you were using JSPs, you also have the option of the jsp:plugin tag?
Use the <applet> tag. For more info: http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

Categories