File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes avoid Applet restrictions on my own machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "avoid Applet restrictions on my own machine" Watch "avoid Applet restrictions on my own machine" New topic

avoid Applet restrictions on my own machine

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I like to run some applets on my own machine.
Of course I trust my own applets, but they like to write to file (same machine) and connect to the sql-server (same machine too) and do a lot of TCP/ IP and UDP connections.
I trust all of them, and the involved machines trust too.
I'm looking for an EASY way to tell all those machines, that my silly little applet is to be trusted.
How do I start?
Where can I find a BRIEF instruction?
(of course I will have to find out the more complex things later).
Looking at the sun docs, I found out how to create a .java.policy - file, but where do I refer to it?
In the test.jar? In the test.html with the applet-tag?
I found no switch for the appletviewer, nor for java.
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
One way to do something you want is to build a java-application
which USES your applet.
U just instantiate your applet and then call yourapplet.init()
naturally after adding your applet to the (Frame e.g.) of you application/
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
The only problem with this approach is that the browser is responsible for creating much of the environment that the applet runs under, so you'd have to recreate a lot of functionality. (Although there are OpenSource libraries already written to do this.)
However, in terms of the *simplest* way to deal with this during development is to use the AppletViewer.
What I do, is first create a policy file named "all.policy". The contents of this file are:

Then I create a batch file to launch my applet in the appletviewer using this policy:

"AppletExample.html" is a third file that contains the <applet> tag for my applet I'm testing . (AppletViewer only parses the <applet> tag)
code for AppletExample.html:

All three files are in the same folder, btw. You can put your classes wherever you want, just make sure the <applet> paramaters reference the code in the right location.
Then when you double-click the batch file, you will be viewing your applet in appletviewer with all permissions enabled.
Hope this works for you.
[ September 05, 2003: Message edited by: Rob Ross ]

SCJP 1.4
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Hey, Rob Ross, this sounds like the answer to my question.
Since I'm working in other areas of my programm I will try this later.
But thanks in advance of testing.
I agree. Here's the link:
subject: avoid Applet restrictions on my own machine
jQuery in Action, 3rd edition