1
<applet archive='AlienWar.jar' code='AlienWarApplet.class' width='387' height='410'>
                                </applet>

I have an applet and its works just fine when I use it in html and have the .jar in the same directory. But now I am building a web application in netbeans(I use JSF framework and Apache Tomcat server). I insert the same code in the index.xhtml and add the .jar to compile time libraries, but i get a classNotFoundExeception.

Where should I put the .jar??

1 Answer 1

3

The Jar needs to be in a place on the server where you could fetch it from if you typed the address in the browser address bar and hit Enter

For a web app., that particularly means. Do not put the archive in the WEB-INF/lib directory you might use for servlet/JSP libraries. That directory is not offered to the end user for browsing.

The code can be made to work by putting the archive in the same directory as the HTML (presuming the HTML is in a location that passes the 'fetch test'), but that is sloppy and might lead to the same Jar being in many directories for many applets.

Instead I would typically put all the applet archives in a single directory at the root of the domain. Specifically (no hard and fast rules here) lib. Specify codebase="/lib" in the applet element and the JRE will look in the http://your.com/lib path for whatever archives are in the comma separated list in the archive attribute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.