Meaningless Drivel is fun!*
The moose likes Applets and the fly likes Conversion of App to Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Conversion of App to Applet" Watch "Conversion of App to Applet" New topic
Author

Conversion of App to Applet

Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
Been struggling with this for a few days and have some general questions for any applet guru's out there

I can compile the applet fine, but it seems to complain if the application is in any sort of package.

Do applets have to be in the default package? The application I'm trying to move over is in your typical com.bus.dir.etc package, but it gives me the class not found error unless I remove the package.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
Applets can be in any package, just like an application. Of course, the applet tag in the HTML page needs to reflect that package by giving the fully qualified classname in the "code" attribute.


Ping & DNS - my free Android networking tools app
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
ah, that would make sense....

another question, in general class files are put under web-inf/classes/etc

but applet can't be placed under the web-inf directory. In general, is it bad programming to have 2 classes directory in a single web application?

I could just get ant to copy the applet files into a separate directory I suppose, but is this common practice?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
You should keep the two codebases apart, as they have nothing to do with each other.

As to the applet classes being part of a web app, well, only in the sense that they are static content that is being served by that web app, like images or HTML pages. There really is no connection to the dynamic content represented by servlets or JSPs.
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
I still can't seem to find the class file even with the full qualified name to it.

I have a directory jars/ that contains my applet.jar file

In the applet.jar file, i have a directory structure as such:

com/buz/foo/poo/myapp.class

and in my html,

<applet code="com.buz.foo.poo.myapp.class" codebase=jars/ archive="applet.jar" width=320 height=300>
<PARAM NAME=id VALUE="411">
</applet>


can you see any reason why the applet would not be able to find myapp.class?
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
Oddly enough, I have 3 jar files that I'm attaching to my applet, 2 of them work fine and are denoted by

basic: Loading http://localhost:8080/jars/blah.jar from cache
basic: No certificate info, this is unsigned JAR file.

which is fine, but for the jar that i'm trying to use as my applet, it is download by:

basic: Downloading http://localhost:8080/jars/player.jar to cache
basic: encoding = null for http://localhost:8080/jars/player.jar

is there any reason why the encoding would be null for this? Any ideas would be appreciated.
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
Thought I would just state that the problem was found in my ant build scripts.

It was for some reason creating duplicate class files for all my classes. Which is weird since compiling created no duplicate class files, it was only when the Jar was created through the ant script.

Removing all duplicates allowed the applet to be loaded correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion of App to Applet
 
Similar Threads
Signed Applet using the javax.comm
Signed applet using javax.xomm
running applet in hta
Signed applet using javax.comm
How to reference Applets in a Java Web Application