aayush anand
aayush anand

Reputation: 35

Integrating a java applet in a page

I am trying to integrate a processing applet in a jsp, with the following code added in the jsp:

<!--<applet code="Test1.class" archive="C:\Users\user\Desktop\MyApplet.jar" width="600" height="600">
</applet> --!>

I am using a tomcat server. The jar contains the Test1.class file. But whenever I run this page, I am getting an error in the webpage. On clicking for details, the message shown is

IllegalArgumentException: name![enter image description here][1]

Upvotes: 1

Views: 3341

Answers (4)

user592704
user592704

Reputation: 3704

In the case you use Tomcat you can deploy the applet as...

  • A) put your jar + its html launch page to the same folder (still I recommend a war file and its WEB-INF folder)
  • B) and configure applet tag as
 <applet code="Test1" archive="MyApplet.jar" codebase="."  width="600" height="600">
    </applet>

To be more... clear the files structure should look like the following tree...

|webapps

||aWarFile.war

|||WEB-INF

|||MyApplet.jar

|||MyAppletLauncher.html (or *.jsp)


Report that helps

Good luck

Upvotes: 0

aayush anand
aayush anand

Reputation: 35

<applet code="package1.Test1" name="myApplet" archive="MyApplet.jar,core.jar" codebase="." width="600" height="600">

The above code got me the result.

Upvotes: 0

Andrew Thompson
Andrew Thompson

Reputation: 168825

Minimalist example:

<applet 
  code="Test1" 
  codebase="."
  archive="MyApplet.jar" 
  width=400
  height=400>
</applet>
  • code - The fully qualified class name (e.g. javax.swing.JApplet)
  • codebase - A . indicates 'the current directory' - where the HTML is loaded from. Although the current directory is the default, I like to make it explicit.
  • archive - Relative path(s) from codebase to archive(s). For simplicity, the archive is assumed to be the same place as the HTML.
  • width/height - Must be specified.

Upvotes: 2

MTranchant
MTranchant

Reputation: 485

You have to use the "codebase" attribute to set the path. Consider to put it in the same folder (or in a child folder of the current one) instead of an absolute path.

<applet code="Test1" name="yourName" archive="MyApplet.jar" codebase="C:\Users\user\Desktop">
</applet>

Upvotes: 0

Related Questions