Reputation: 776
I have a Java program that includes several directories and I would like to turn it into an applet. For that purpose I have embedded the class which will have the start
and paint
methods like so:
<applet code="appletClass.class" width="450" height="420" codebase="myProgram/bin/">
</applet>
Now, the appletClass.class
file is in myProgram/bin/
, but other classes that appletClass.class
calls to and instantiates are among several other folders (some are myProgram/bin/ca
, myProgram/bin/de
). Does the JVM automatically know which subfolder to look for if I use import
statements in appletClass.java
or is there some way to include multiple subdirectories in the embedding so that when I instantiate objects defined in different directories the application works?
Upvotes: 0
Views: 101
Reputation: 168825
Does the JVM automatically know which subfolder to look for if I use import statements..?
Yes it does.
But then, Oracle recently cracked down on the security environment of applets to the point that an unsigned applet is unlikely to get launched at all. So follow the advice of @sasankad and Jar the classes (then digitally sign them).
Upvotes: 1
Reputation: 3613
you need to first create a jar file consisting all your class files as follows
then follow the below instructions
Sun developed a generic JavaScript to handle all the specific browser quirks, so that you don't have to worry about browser compatibility.
Add this to your section:
<script src="//www.java.com/js/deployJava.js"></script>
And this to section:
<script>
var attributes = {codebase: 'http://my.url/my/path/to/codebase',
code: 'my.main.Applet.class',
archive: 'my-archive.jar',
width: '800',
height: '600'};
var parameters = {java_arguments: '-Xmx256m'}; // customize per your needs
var version = '1.5'; // JDK version
deployJava.runApplet(attributes, parameters, version);
</script>
See Java™ Rich Internet Applications Deployment Advice for a detailed explanation of the script and all the possible options.
Upvotes: 2