Can't load Java applet from another directory in HTML - java

When i try to load an applet with :
<object type="application/x-java-applet" height="300" width="550">
<param name="code" value="Sokoban" />
</object>
when the html file is in the same directory as the applet it loads as expected.
But when the applet is in an another directory the following code won't work :
<object type="application/x-java-applet" height="300" width="550">
<param name="code" value="sokoban/Sokoban" />
</object>
(sokoban is the directory the applet is in, Sokoban is the applet => Sokoban.class)

Use deployJava.js to deploy the applet (linked from the applet info. page).
Use the codebase attribute to point to the sokoban directory.
Since the code attribute needs to be the fully qualified class name, return it to just Sokoban

Related

Running an applet - Blocked by Security

Basically, what I am trying to do is run an applet.
I made applet, tested it (offline, from Eclipse), exported .jar file and posted on dropbox.com. Then I made simple hmtl which should run that applet.
However I can't get pass the Java security (keep getting "Application Blocked by Java Security" error), even after adding dropbox to "Exception Site List" in Java Control Panel.
<!DOCTYPE html>
<html>
<head>
<title>
My Title v3.0
</title>
</head>
<body>
<object width="480" height="360" data="MyNumber.jar" type="application/x-java-applet">
<param name="codebase" value="https://www.dropbox.com/s/mz6y145mwdtge7r/MyNumber.jar?dl=0" />
<param name="code" value="mynumber.online.MyNumberOnline />
<param name="width" value="480" />
<param name="height" value="360" />
<param name="archive" value="MyNumber.jar" />
</object>
</body>
</html>
Is there a way to get past this?
You have to sign this applet with a certificate as the dialog says "identified by a certificate".

Access COM Port on Client Side in Web Programming Java

I am developing a Web page using jsp and html where in I need to read/write from/to a Device connected on Client's System who are accessing the Webpage. The Device is a Serial Device which is connected as COM1(Eg) in Windows. I went through different options available. I found this which serves my purpose. I started learning JNLP for the same. I imported the project and made changes according to my needs. (This project is using jssc.jar). I generated the jar (jSSC-Terminal.jar) and signed with self-generated key. The GUI is being loaded properly but I am unable to access the Serial port on client's machine. Here is my jnlp file launch.jnlp
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp href="launch.jnlp" spec="1.0+" codebase="http://192.168.1.33:8080/abc"
href="launch.jnlp">
<information>
<title>jSSC-Terminal</title>
<vendor>scream3r</vendor>
<homepage href="scream3r.org"/>
<description>jSSC-Terminal</description>
<description kind="short">jSSC-Terminal</description>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+"/>
<jar href="jSSC-Terminal.jar" main="true"/>
<jar href="jssc.jar" download="eager"/>
</resources>
<applet-desc height="500" main-class="applet.Main" name="Main" width="700">
<param name="separate_jvm" value="true"/>
<param name="draggable" value="true"/>
</applet-desc>
</jnlp>
Here is my html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jSSC-Terminal</title>
<style type="text/css">
body {
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<applet code="applet.Main" archive="http://192.168.1.33:8080/abc/jSSC-Terminal.jar, http://192.168.1.33:8080/amar/lib/jssc.jar" width="700" height="500">
<param name="separate_jvm" value="true"/>
<param name="draggable" value="true"/>
</applet>
</body>
</html>
I have placed all these files in Tomcat directory as below
/Tomcat/webapps/abc/launch.jnlp
/Tomcat/webapps/abc/jSSC-Terminal.jar
/Tomcat/webapps/abc/index.html
/Tomcat/webapps/abc/lib/jssc.jar
I am unable to get the SerialPort List when run as jnlp. Kindly help me out with a fix if available. Or are there any alternate things available in JSP. Thanks and Regards.
Edit :
Finally found out thank you. I replaced my applet tag and included jnlp location as below :
<applet code="applet.Main" archive="http://192.168.1.33:8080/abc/jSSC-Terminal.jar, http://192.168.1.33:8080/abc/lib/jssc.jar,"http://192.168.1.33:8080/abc/test.jnlp" width="700" height="500">
<param name="separate_jvm" value="true"/>
<param name="draggable" value="true"/>
</applet>
</body>
Your <applet> tag doesn't refer to the .jnlp file. You give access to COM ports in the jnlp file but it's not being used. You have to either use the jnlp file or set permissions in the <applet> tag.
Your link to the jssc example is a page that shows how to use the jnlp file from the <applet> tag.
I've done what you are trying to do with a Java Webstart app and the PureJavaComm library. I bet what you are doing will work once you get the permissions right, though. But if you want to have a look at how I set this up the jnlp file is here: https://bitminter.com/client/bitminter.jnlp (live app)

ClassNotFound for AppletLoader when exporting a libGDX applet

I tried following this to export my libGDX game as a Java applet. The guide was a bit confusing so I might have done something wrong here. This is what I did:
My libGDX game, in Eclipse, looks like this:
Game
Game-Android
Game-Desktop
The desktop game works fine.
As the guide says, the desktop project uses the Lwjgl backend.
Then I created a GameApplet.java in Game-Desktop/src/my.package.name containing
package my.package.name;
import com.badlogic.gdx.backends.lwjgl.LwjglApplet;
public class GameApplet extends LwjglApplet
{
private static final long serialVersionUID = 1L;
public GameApplet()
{
super(new Game(), false);
}
}
I created a directory applet in Game containing
gdx.jar
gdx-backend-lwjgl.jar
gdx-backend-lwjgl-natives.jar
gdx-natives.jar
lwjgl_util_applet.jar
I right-clicked Game in Eclipse and exported it as a JAR with the following settings:
Resources to export:
- Game
-- src
-- libs
Export generated class files and resources
The exported JAR (called Applet.jar) was placed in the applet folder.
I created the index.html file containing
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>HelloApplet!</title>
</head>
<body>
<div id="applet_container">
<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">
<param name="al_title" value="HelloApplet">
<param name="al_main" value="my.package.name.GameApplet">
<param name="al_bgcolor" value="000000">
<param name="al_fgcolor" value="ffffff">
<param name="al_jars" value="Applet.jar, gdx.jar, gdx-backend-lwjgl.jar">
<param name="al_windows" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_linux" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_mac" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="al_solaris" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
<param name="codebase_lookup" value="false">
<param name="java_arguments" value="-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -Xmx800M">
<param name="lwjgl_arguments" value="-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true">
<param name="separate_jvm" value="true">
<param name="codebase_lookup" value="false">
</applet>
</div>
</body>
</html>
I signed the files and uploaded them to my site. On Firefox, OSX, I get a message saying
ClassNotFoundException
org.lwjgl.util.applet.AppletLoader
What did I do wrong?

Iframe over applet flickering

I am using a iFrame to show content over my Applet in my online game.
It work's perfectly in Safari, Chrome, Firefox, Opera etc. But as always not in Internet Explorer on Windows.
When the iframe opens over the applet, the content become to "Flickering"/"Blinking" like the applet is updating a lot, which it doesn't.
What can i do? I am using this:
<applet id="applet" code="main.AvatarClient.class" archive="qqqqqAvatarClient.jar" name="Chat" width="760" height="582" scriptable="true" MAYSCRIPT="true" >
<param name="cache_option" value="YES" / >
<param name="localization" value="locDK/" />
<param name="userName" value="<?=$user?>" />
<param name="password" value="<?=$pass?>" />
And the overlay where iframe is:
<div class="add-block qw no-rounded-borders" id="wo" style="position:absolute;left:756px;margin-top:-30px;z-index:99999999999999999999999999999999999999999999999999999999999999;height:380px;width:495px;display:none;">
<iframe id="my" src="loading.php" frameborder="0" height="380" width="496" scrolling="no" style="z-index:9999999999999999999999999999999999;position:absolute"></iframe>
</div>

launching java applet

As far as I can see from the documentation, <applet> is deprecated, and the <object> tag is the preferred method for launching an applet now. But I can't find decent documentation, or even a tutorial on how to use the object tag to launch an applet.
I did see the following question which shows how in javascript but I would prefer to use a tag
launch applet from web page
I need to know how to specify the java engine, how to specify a jar file, where it's stored, and how to specify the class that is executed.
Here's what i have at the moment (but does not work)
<object
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="800" height="600" data="pi.jar">
<param name="code" value="PiLauncher.class"/>
</object>
the claim was in the Oracle 1.5 docs that this classid specifies "the current java engine" but this is completely opaque to me. They also had examples requesting a specific version.
Even if this is true, how do I:
specify the jar file
specify the class (is this correct above)
specify the directory where the code is (is codebase still valid?)
First of all, the syntax is not the same for firefox and IE:
Firefox:
<object classid="clsid:CAFEEFAC-0017-0000-0000-ABCDEFFEDCBA" id="appletId" name="appletName" width="400" height="300">
<param name="code" value="com.myPackage.Applet" />
<param name="codebase" value="../resources/applet/"/>
<param name="ARCHIVE" value="myApplet.jar" />
<param name="cache_archive" value="myApplet.jar" />
<param name="type" value="application/x-java-applet" />
<param name="cache_option" value="plugin" />
<param name="mayscript" value="true" />
// you can set optional parameters here
</object>
IE:
<object width="400" height="300" classid="java:com.myPackage.Applet.class" codebase="../resources/applet/" name="appletName" id="appletId">
<param name="archive" value="myApplet.jar" />
<param name="type" value="application/x-java-applet" />
<param name="cache_option" value="plugin" />
<param name="mayscript" value="true" />
// you can set optional parameters here
</object>
Here is a good link: http://docs.oracle.com/javase/1.5.0/docs/guide/plugin/developer_guide/using_tags.html#object

Categories

Resources