Java applet loads in Netbeans applet viewer, but freezes browser - java

I've written a simple applet which performs some operations on text it retrieves from a TextField, based on a dictionary kept in a separate file.
In init(), the applet reads the file (8000 lines) and stores its content in an object. I'm using Netbeans 6.9 and I can successfully deploy the applet within the IDE; it runs flawlessly. However, I can't get it to work in any browser. Initially, the associated .html file only loaded the .class. Then I learned about policies and I created a signed jar instead, allowing it to read any file. The browser (Firefox in my case) detects the certificate, I authorize it, it then detects unsafe operations, I authorize those as well, then it simply freezes. The file is where it's supposed to be, the paths are correct, jconsole shows no exceptions being thrown - just permanently increasing memory. The file is really small compared to memory usage. Does anybody have any ideas as to why this might be happening? Thank you!

Related

Remove warnings coming in my web page while using applet

I have newly created one website.it contains applet.But while loading it shows a security warning.
Resize multiple images online without losing quality
Plaese tell me how to remove this warning.
I have tried browsing in google, as I need to access the file system, I think I have to sign the jar file. How to sign the jar file so that there should not be any warning like in the page?
Resize with Custom dragging and create template and resize n number of images with high performance
Explain me all the steps while dealing with applet.
It is not possible to get a Java applet launched without warnings. This is for the protection of the end user and cannot be changed no matter what we might do.
An applet that accesses the local file system certainly could never be launched without warnings.

Trouble with Viewing Updates to Applet on my Website

So I have a website and I'm putting an Applet on it, and every so often, I update and re-upload that Applet. However, I cannot seem to view the changes I made to the Applet only. I am able to update and re-upload the index.html file, and I can view the change immediately, but It takes a day for me to be able to see the update I made to the Applet.
The odd thing is that my friends are able to see the change I made to the Applet immediately, so I know that the upload did work.
Yes, I have tried clearing my cache and restarting my browser, but that does not seem to work.
Open the Java Console & flush the class cache, then refresh the page.
For more reliable and controllable updates, deploy the applet using Java Web Start. For a better experience generally, deploy the app. as a JFrame using JWS.

Read access only applet in a dynamic enviroment

I have moved on to make my first applet and was zooming thru everything faster then i anticipated and now i have hit a snag. The applet is designed to work in a dynamic environment where it will read a specific folder and all of the files in the sub-folders in that folder. The problem I am having is that once it is established on my test server it gives:
access denied("java.io.FilePermission" "\basefolder" "read")
My research has told me that this is because applets in particular are untrusted to begin with. Unfortunately solutions there are a many i have tried a few but none of which seem to work. I am currently using eclipse for creating my applet. So if i am trying to make an applet that reads and displays information on a website from a dynamic folder on a file server what is the best way to grant these permissions?
..what is the best way to grant these permissions?
The problem is not exactly as you expect. The bottom line is that an applet cannot create a File object on a server (for e.g. to get the file list of a directory). That is not because of permissions, but just the way that files & servers work.
To get the file list will require help from the server. And by 'help' I mean the server providing a file list that the applet can read.
If the server is set up to provide the list, and the applet is hosted from that server, it requires no special or extra permissions.

How can I set my Java applet's working directory in IDEA?

I have been using IntelliJ for a while now and I'm enjoying its suite of features but I'm having a hard time getting the run configurations to work for a java applet. I have a pre-existing Java tool that uses Swing and I'm using the JApplet class to load those GUI objects as an applet. The problem is I have a couple configuration files that I need loaded. I load these from the working directory and from my knowledge, this working directory would normally be the directory in which the applet resides. I think the major problem is IDEA sets the startup variable:
-Didea.launcher.bin.path=IDEA_BIN_DIR
I would like to be able to change this but I am seemingly unable to. I have tried overriding this flag by editing the applets run configuration VM parameters, but IDEA will continue putting the above one in even if I specify something different.
So in short, I'm having a hard time loading a local configuration file because I can't set the working directory for the run configuration in IDEA. Does anyone know how to get around this or know of a better way of running Java applets that use configuration files, in IDEA?
An applet normally runs in a sandbox in a browser, and such an applet can't access the local computer's file system, for security reasons.
Thus it is generally a bad idea to load configuration files from the file system, and "working directory" is not a useful term for an applet.
If these files change seldom (i.e. in principle only by the developer), you can put them to the applet's class files (i.e. in the jar file, or during development in the directory where the classes will be generated), and use class.getResource() or .getResourceAsStream() to load them.
If the configuration files should be definable by the webmaster, put them on the webserver - either at some fixed location relative to getCodeBase() or .getDocumentBase(), or specify them as parameters to your applet tag in the HTML tag.
If these are user specific configuration files (which the applet should be able to write), you either need to store them on the server and retrieve/store after a login (i.e. you need some logic at the server side), or you would store them at the client side.
The current way to do this would be using the JNLP API (in javax.jnlp.*) - there are some interfaces allowing Persistence, or loading/storing data (with the user having a FileChooser). Alternatively, you could sign your applet and request an AllPermission from the user - then you can access the file system.
Sorry, nothing of these answers your original question (I don't use IDEA), but maybe these help you to find another way.

Applet will work in IE, but not firefox

So I have created an applet that creates a file on the local hard drive, and eventually uploads it to a CGI that I have created.
When run on IE, the applet works fine, and creates and uploads the file properly.
However, on firefox, I get an error on the Java Console, access denied, showing me that it simply can't create the file. I created the certificate myself, and did not buy one or have it verified through a company.
I need a solution that will work for anybody who potentially uses the applet, meaning the fix can't just be editing my own settings, unless I can do that with every computer that accepts the certificate.
Unsigned applets cannot access local disk on all browsers. It worked for you in IE because I believe that you ran it from file system (not via http). So, the right solution is not to create file on disk. Create content in memory and upload it. But remember: you can connect only to server the applet was downloaded from.
If you really have to create local file you have to sign the applet.
May be, some setting has to be done. One of the reason could be your Mozilla Firefox is not java enabled.
Check the following links :
A fix for Java applets not loading in Firefox
Applet loads but hidden in Firefox
To test whether java is enabled or not in a web browser, click [here]
This bug may be relevant.
It states that Firefox kills java applets that take too long to load. I have an example that works fine when loaded from a local resource but fails when it is remote. Sometimes, reopening the applet can make it work as it appears that it loads more and more of the classes each time.

Categories