Forum Stats

  • 3,872,061 Users
  • 2,266,374 Discussions
  • 7,911,043 Comments

Discussions

Applet and JARs

jvr Guest
jvr Guest Member Posts: 8
edited Feb 9, 2011 5:45PM in Java Applet Development
Hi,

I have created a little applet that calls to a method of a class stored in a jar file which is allocated in the JAVA_HOME/jre/lib/ext/myfile.jar in my computer.

It works, the code at the myfile.jar works correctly in my computer.

The problems begins at the moment to execute the applet in the webserver.
I have saved the myfile.jar at JAVA_HOME/jre/lib/ext/ at server and the applet is on the web root directory. like in my computer.

It works when I have the myfile.jar in my computer at JAVA_HOME/jre/lib/ext/
but when I have deleted myfile.jar in my computer, the class is not found when the applet tries to be executed.

How can I do that the applet, call to methods in the class of myfile.jar in the ext dir at the server?

Is need a servlet?
Tagged:

Answers

  • User_64CKJ
    User_64CKJ Member Posts: 7,279 Silver Badge
    BKD wrote:
    ..How can I do that the applet, call to methods in the class of myfile.jar in the ext dir at the server?
    You can't. Servers do not allow external clients to get resources from 'any' place on the server, but just very specific places defined to be open to the public. In any case:
    <li> An archive starting with "my" should never be ending up in the sub-directories of a Java installation - for either development or deployment.
    <li> Developers with as little imagination as prefixing things with 'my' deserve 20 lashes. But I realize, that is my problem - I will deal with it (places back of hand to forehead).
    Is need a servlet?
    No. Just make the Jar available in a public place on he server (one place that usually works is the same directory as the HTML - simple but effective) and add a reference to it in the archive attribute of the applet element.
  • jvr Guest
    jvr Guest Member Posts: 8
    edited Feb 9, 2011 6:02AM
    Hehehe

    Hi Andrew,

    Is not really the name of the file is an assumed name.

    Anyway the name of the file is not a problem for me.

    Really I could write all the code in the applet or I could save the other one jar file in a public place like you said, but there is a nonpublic information that I don't want to make very accessible because a jar file is easy to download and decompile it.

    Then I created 2 jar files, instead of 1 and I would like to the one with the nonpublic data will not be stored in a public place.

    Any suggestion?
  • sabre150
    sabre150 Member Posts: 1,405
    BKD wrote:
    Then I created 2 jar files, instead of 1 and I would like to the one, with the nonpublic data will not be stored in a public place.
    The 'public' jar has exactly the same access rights as anything else running in your browser so if it can get at your 'private' jar then anything in the browser can. You can't change this.
  • EJP
    EJP Member Posts: 32,920 Gold Crown
    a jar file is easy to download
    Exactly, and that's what the browser does when it loads your applet. So it has to be downloadable. If you have security or privacy concerns about your application you will have to find another solution.
This discussion has been closed.