I'm trying to figure out how difficult it would be to convert a Java Web Start app to an applet. Theoretically, if the application didn't do anything such as write to the file system...basically if all of it's actions should be safe within the Applet sandbox, how tricky would it be? Is it a matter of wrapping the main app inside of an applet?
It should be quite straight forward. Simply create an applet class. From within the applet class you can instantiate whatever class JWS would normally start.
You then need to convert the JWS xml file to an applet tag and put it on a web page.
Related
I need to automate a Java Applet which sits inside an IE only website. I know I can use the Java Access Bridge to interact with Java applications but I'm having trouble finding out how to hook it up to an Applet.
I am aware of a Java Bridge method called GetAccessibleContextFromHWND(..) which I thought I may be able to use. Unfortunately when I use Spy++ to try and get the Applet's HWND, I comes back blank so it seems this can not be done using the usual FindWindow(..) Windows API function.
How can I access and control Java Applets using the Java Access Bridge?
1.Find Applet tag from HTML page and get position(Height/Width) of it.
2.Move your cursor toward Applet center position with reference of IE window.
3.Use **getAccessibleContextAt** API and use Applet x,y position.
4.Get Accesiblecontext from above API.
5.Iterate to root level Accesiblecontext. Finally you will get first object of Applet window.
I have an Applet that I would like to convert to a JWS file because of all this problem with compatibility with Chrome (and now, Edge). The problem is that I never used this technology so I would like some help.
Is there a step-by-step guide on doing this conversion? I mean, I have a class that extends java.applet.Applet implementing init and start, how do I change it to a JWS/JNPL class? And can it receive parameters like the applet?
We don't need it to run in the browser, so downloading and executing is fine. But it would be better if the browser executed it right away, instead of the user clicking on file downloaded. Is that possible?
Is there a step-by-step guide on doing this conversion?
The JWS info. page here at SO has all the best JWS related links I could think to include.
I mean, I have a class that extends java.applet.Applet implementing init and start, how do I change it to a JWS/JNPL class?
By Jarring the classes and digitally signing the Jars (if not already done) then writing a JNLP file to launch it (and possibly configuring the server to return the correct content-type for a JNLP file).
And can it receive parameters like the applet?
Yes, they are specified in the JNLP file.
Originally I had an applet that contained SQL server/jdbc stuff and wanted to use that applet in html but I guess it's not good to use SQL in html? because i kept getting millions of errors/exceptions and realized my applet would only work if i commented out my SQL code.
but anyways, is there a way that I can have a button on an html page that when it is clicked it will run the runnable JAR application not the applet? without causing errors..
I'm not sure what a JAva Web Start is or what a JNLP is but if anyone could explain/help? the Oracle Website doesnt explain well enough like how do i create a JNLP?
I currently have a runnable JAR file that was exported from eclipse that opens & runs when I click the icon
You are correct that Java Web Start is what you want to use. You have your JAR file built already, so you should be good to go by following this Deploying a Java Web Start Application tutorial
This will walk you through signing the JAR file, creating JNLP file. This web site contains an example of a JNLP file, and also contains more documentation on the structure of the JNLP file here
You'll then create a few simple lines of JavaScript, to be triggered when the user clicks a button. Something like this, as mentioned in the tutorial:
deployJava.createWebStartLaunchButton(URL_TO_JNLP, '1.7.0');
I currently have a in-development Java Game.
It runs from a .jar, with all the image files inside. The .jar creates and accesses files in the working directory.
I was wondering if there was a simple way to put this on a webpage as a Java Applet. I currently have Applet code in the Game, but all it does is calls the normal main method to create JFrames and run the game.
I need a simple way to run this on clients from a webpage, prefferably an applet? Is there one?
Please note, I didn't actually make this as an Applet at first. It's currently a .jar, with a .bat to run it. My "Applet" class is this simple...
package explorer.applet;
import java.applet.Applet;
import explorer.boot.Startup;
#SuppressWarnings("serial")
public class ExplorerApplet extends Applet{
public void init()
{
Startup.wp = true;
Startup.main(null);
}
}
I was wondering if there was a simple way to put this on a webpage..
Sure. Launch a JFrame direct from a link using Java Web Start.
..as a Java Applet.
Why? Applets are harder to deploy and maintain, and provide a less satisfactory experience to the end user.
Note that the fundamental problem is the same either way. 'How to access an application resource?'
Such resource access would be by URL. There are these 2 primary alternatives:
Add the resource to the Jar and use Class.getResource("/path/to/the.resource")
Put the resource 'loose' on the home server, and form the URL relative to the code base or document base of the applet, or the code base of the JNLP (the file used to configure a JWS launch).
The .jar creates and accesses files in the working directory.
About 4MB, and they store the game information. (It's a 2D world game.)
They also have to be client side, and in the folder that the "jar" runs from.
That is too large for any of the sand-boxed techniques I had in mind, but since it is 'static'1 resources - they can be added to a Jar which is on the run-time class-path and thereby will be 'downloaded and made available to the app.'.
Access the resources as described above.
By 'static' I simply mean 'do not need to be edited or changed by the user or app.', as opposed to something like 'high scores' which must logically be written by the app. on game exit. It is still possible to update the maps, all you need to do is provide the updated Jar and Java will do the rest.
No. Not pressing PRT Screen. But here is what I want. And I need to know if it can be done and by what means :D
Okay so I have a java applet that runs and displays a walking man.
I need it so when I access a script (in some web scripting language) it takes a "screenshot" of that applet and then saves it on the server. Is this possible? and by what scripting means could I do it?
Thanks in advance!
If there are heavyweight components they might not come out, but the obvious way is:
Create a java.awt.image.BufferedImage
Call createGraphics to create a Graphics instance.
Call update(Graphics) on the applet.
Find a tutorial for converting the BufferedImage to a wire file format.
POST back to the web server.
You can use LiveConnect to connect both ways between Java and JavaScript. It's usually easy to add Java code to an applet simply by adding another reference to the archive attribute of the applet tag.
There are plenty of tutorials on the various parts. I've never done it myself.