java appletviwer will not load images from documentBase - java

We are developing a prototype on an old TV box that runs Java applets (via PersonJava JRE 1.1.8). The box runs applets great, no problems.
However, we would like to use appletviewer (from Java 8) to develop locally. However, appletviewer is not able to load images from the documentBase. Images load fine in applet on the TV Box, the problem is in appletviewer.
We understand that applets are deprecated, but we would still like to have a nice development process for this project. Alternatively, are there any other easy ways to run applets in 2021?
In the appletviewer this code:
bgImage = getImage(getDocumentBase(), "myImage.gif");
leads to this error:
java.security.AccessControlException: access denied ("java.net.URLPermission" "http://localhost:8080/applets/hello/myImage.gif" "*:*")

It seems like the appletviewer program is broken. Despite various attempts to set security policies, the appletviewer does not allow downloading images from the remote documentBase (as an applet allows). This makes developing applets a bit challenging, because there is no simple way to run an applet in 2021.
Our solution is to build out the entire code base as an awt.Container, which can be loaded locally into an awt.frame for developement, and then also deployed into an applet for the prototype running on the TV Box. An awt.frame can do most everything an applet can do, so it works well.

Create a file grant-all.policy with the following contents:
grant {
permission java.security.AllPermission "", "";
};
and run the applet with
appletviewer -J-Djava.security.policy=grant-all.policy https://the.url.to/your.applet.html

Related

Made a .jar file of an app I made using JFrame in java. Which works 100%. But when I have it loading from a website, its just a blank white screen

So as I tried to describe in the title.
I made an application that works 100% when compiled, and also when opened with the .jar file I made for it.
So my next step was to run this from my online portfolio. However, when I use the
<APPLET ARCHIVE="xxxxx.jar" CODE="xxxxx.class" WIDTH=400 HEIGHT=300>
</APPLET>
approach... So the Applet prompts me to run, I click Yes. My JFrame pops up like it normally would, however it is just a completely white blank screen. ( no content from my app )
I must have them linked appropriately if the JFrame even loads at all. So I'm not sure whats up.
Any help? Thanks
Edit: I forgot to mention, I am running this locally at the moment. Not sure if they would have anything to do with anything.
What method would I use to upload a .jar file to be executed from a web page?
For deploying Java desktop apps., the best option is usually to install the app. using Java Web Start. JWS works on Windows, OS X & *nix.

networking applets not working in chrome

I have recently created a Java applet which creates a socket and performs some networking functions. The applet works fine when run in an applet viewer. But when i try to run it in a
google chrome, it is launched but its not performing the desired function.
I used (ofcourse) java.net library and my applet runs without a main method.(Old applets unlike swing components).
Is not having a main method a problem ??? Please help :) thanx
Actually after a bit of research i came to know that Java applets have many restrictions due to security reasons... which include specially on creating the SOCKETS!!.
If you really wanted to communicate using Applet then you have to run it independently, to accomplish this you should have the applet digitally signed which is too tough to obtain.
Instead you can create the JAR version of the applet and then convert into exe application using jar2exe converter and use it.

Java applet run from web page cannot be Run

Hello I Create a Java applet and run successfully (when press button the notepad Run) form netbeans but when run the Application from web page the notpad.exe cannot be run
a Java applet run by default in a "sandbox" that means, it can't access to the user's file system and program.
When you try it, in your netbean, it's different because the "sandbox" isn't apply.
What Applets Can and Cannot Do
Maybe it's not allowed for java applets to run notepad on user's computer ?
You have to get applet signed, so that you can access Native programs(.exe). Like said above, Currently its working in sandbox mode. sign the applet and it will work

how to run Applets on Safari(web browser)

hii every one
good morning
I have created one project on JApplet
it runs successfully on Applet window
but i want to run it on web browsers(Internet explorer , Mozilla firefox, Safari, etc.)
I m using Mac os x and i want to run it on Safari.
You have to create an html which refers to the applet. Open the html in browser.
Take a look here for the applet tag http://www.w3schools.com/TAGS/tag_applet.asp
Using Mac OS X, in /Applications/Utilities you'll find Java Preferences.app. In the Advanced tab, you can enable the Java Console, which may tell you more about what's wrong when you open your HTML page in a browser.
Also, you can edit your question to add code, etc.
Addendum: You might want to start with a known working example.

Possible to launch JWS applet within browser instead of standalone?

Is it possible to embed an applet in HTML so that it will be displayed within the browser window yet launched through Java Web Start via a JNLP file instead of using the browser's Java plugin? If so, how is this done?
I've only been able to launch my applet in a standalone window, but disliking the user experience pop-ups create, I'd prefer that it be embedded in the browser window.
I'd like to use JWS instead of the plugin because I need to control my applet's maximum heap size, which I don't believe is possible with the browser plugin, at least not on Mac OS 10.5.
In-browser applets support JNLP deployment since 1.5 (or so). There's an example on how to do it here: http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html
You're still using the Java plugin then, of course. It may or may not work to set the heap size.

Categories

Resources