File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run applet in browser

 
Nisha Kala
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one please tell me how to run applet in browser.

I followed the steps from http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html

When i run appletviewer -J-Djava.security.policy=Write.jp http://aURL.com/SignedApplet.html
it showed error - I/O exception while reading: Server returned HTTP response code: 403 for URL: http://aURL.com/SignedApplet.html.

So i gave -J-Djava.security.policy=Write.jp http://localhost:8080/SignedApplet.html and it showed error I/O exception while reading: http://localhost:8080/SignedApplet.html

Can anyone help me out to solve this?
 
Rob Spoor
Sheriff
Pie
Posts: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our Applets forum.
 
Arka Sharma
Ranch Hand
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

Are you closing applet tag like as following in your html document

<applet code="<your applet class" height="200" width="200" />

End the tag with </applet>.Perhaps it will work.

Regards,
Arka
 
Nisha Kala
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my html code
<applet code="SignedAppletDemo.class"
archive="SSignedApplet.jar"
width=400 height=400>
<param name=file value="/etc/inet/hosts">
</applet>

I closed with </applet> only
 
Nisha Kala
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Its working if i give
appletviewer -J-Djava.security.policy=WriteFile.policy file:///home/pearlin/applet/SignedApplet.html

What should i do if i want it to run in localhost

 
Andrew Thompson
Ranch Hand
Posts: 77
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Solve that 403 from the server first. Nothing the applet itself does, can sort that.
  • It seems strange that this applet is in a Jar called SSignedApplet.jar (should that be a single 'S'?), yet you are messing with policy files. Policy files are no good for anything but development. Forget them. If the Jar is signed, the policy file is redundant, you should be seeing a prompt to trust it. If it is not signed, sign it.
  • Note also that sand-boxed applets can access the local file system using new functionality introduced to applets in Java 1.6.0_10.

  • Why is this an applet rather than an app. launched using Java Web Start?
     
    Nam Ha
    Ranch Hand
    Posts: 50
    Java
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Note also that sand-boxed applets can access the local file system using new functionality introduced to applets in Java 1.6.0_10.


    Really??? How is it possible in Java 1.6?
    I have been thinking that accessing local file system is always restricted so we must sign or add permission to the applet.
     
    Andrew Thompson
    Ranch Hand
    Posts: 77
    5
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nam Ha wrote:
    Note also that sand-boxed applets can access the local file system using new functionality introduced to applets in Java 1.6.0_10.


    Really??? How is it possible in Java 1.6?
    I have been thinking that accessing local file system is always restricted so we must sign or add permission to the applet.


    You have not kept up with the times.

    See the last two links under the 'See also' section of this applet info. page. For a demo of the abilities for accessing the local file system (in a sand-boxed app.), see the File Service demo..
     
    Nam Ha
    Ranch Hand
    Posts: 50
    Java
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,

    I think you are confusing between Applets (they are embedded in web browsers) and Java Web Start JNLP (java programs that are downloaded on client computers and being executed as normal java programs).

    Here is some statements from http://download.oracle.com/javase/tutorial/deployment/applet/security.html:


    Unsigned applets cannot perform the following operations:

    They cannot access client resources such as the local filesystem, executable files, system clipboard, and printers.
    They cannot connect to or retrieve resources from any third party server (any server other than the server it originated from).
    They cannot load native libraries.
    They cannot change the SecurityManager.
    They cannot create a ClassLoader.
    They cannot read certain system properties. See System Properties for a list of forbidden system properties.


    and:

    Signed applets do not have the security restrictions that are imposed on unsigned applets and can run outside the security sandbox.
     
    Ulf Dittmer
    Rancher
    Pie
    Posts: 42966
    73
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nam Ha wrote:
    Note also that sand-boxed applets can access the local file system using new functionality introduced to applets in Java 1.6.0_10.

    Really??? How is it possible in Java 1.6?
    I have been thinking that accessing local file system is always restricted so we must sign or add permission to the applet.

    While signing or changing permissions is not required for JNLP, the user must still consent to the action explicitly. So the principle still holds, even if the technicalities have changed.
     
    Andrew Thompson
    Ranch Hand
    Posts: 77
    5
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nam Ha wrote:..I think you are confusing between Applets (they are embedded in web browsers) and Java Web Start JNLP (java programs that are downloaded on client computers and being executed as normal java programs). ...

    I think you are wasting your time, my patience, and the OP's bandwidth.

    Here are 3 projects.
  • A conventional embedded applet.
  • A conventional JWS free-floating app.
  • An embedded applet configured using JWS.

  • The last is the one that is a sand-boxed applet, but still can open local files. (And yes, I developed all 3, so I have no confusion about the distinctions between them.)

    The knowledge to not make silly statements like the one you did, was contained in the links in my earlier post that you apparently ignored or misunderstood (and I also wrote the blurb to which I linked). I suggest you make sure you understand them, before making further comments on related matters.
     
    Andrew Thompson
    Ranch Hand
    Posts: 77
    5
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ulf Dittmer wrote:
    While signing or changing permissions is not required for JNLP, the user must still consent to the action explicitly. So the principle still holds, even if the technicalities have changed.


    The user experience is quite different.

  • The old way demanded 'all or nothing' permissions before the applet ever appeared. If refused, it was hard to get another sight of the dialog that prompted us to allow it.
  • The new way asks permission only when the user goes to use that functionality, and only for that functionality. So the user selects the `Open File` menu item, and sees a warning to the effect 'The app. has requested read/write permission for local files'. Since the user selected the menu item, this prompt is much easier to understand, and more likely to be approved. Further, they can refuse it as many times as they like, and still produce another prompt by selecting 'Open File' again.
  •  
    Nam Ha
    Ranch Hand
    Posts: 50
    Java
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew and Ulf,

    Thank you very much for your information. I learned a new thing
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic