Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems finding applet class file after ant build.

Status
Not open for further replies.

prmckee

Programmer
Jul 27, 2004
8
0
0
IE
Can you help?

When I look at the contents of the war file created by ant, it gives me a path .

If I use this in my APPLET tag in my html file, and try to load the said apple, I get a:

load: class /oplog/WEB-INF/classes/jsp_beans/ReadCodePicker.class not found.,

jsp_beans, is a package which I am storing the applet in (just for convenience).

The following this the HTML code used to load:

<APPLET code="/oplog/WEB-INF/classes/jsp_beans/ReadCodePicker.class"

width=600
height=75>
<param name='driverName' value="com.mysql.jdbc.Driver">
<param name='databaseName' value="HospitalOPDB">
<param name='userName' value="root">
<param name='password' value="">
</APPLET>

The following in the path found for the applet when I inspect the war file:

PATH -> WEB-INF/classes/src/jsp_beans
CLASS -> ReadCodePicker
EXT -> class

I have this applet working if I don’t build the project with Ant, but ant is so cool I would like to keep it..

Using System:

NetBeans IDE 3.6
Apache Tomcat/4.1.29
JVM Version 1.4.2_04-b05
OS Name Windows 2000 (5.0)
OS Architecture x86
JDBC mysql-connector-java-3.0.14-production-bin.jar (com.mysql.jdbc.Driver)


Any help would be great..
 
OK
I found out the A solution to my own problems of getting an applet and its required resources in the correct place to run using ant.

It should be noted that this is ‘A’ solution; but I am not saying that this is necessarily the most correct one.

My solution is to create an applet directory to complement the web and src directories used for placing html, jsp, resource and source files (as per the jakarta wed directory structure) for ant to find them for compiling and deployment.

In this applet director I place the applet .java files and associated resource files used, such as image files, and driver jar files required to run your applet.

In the ant script you create a separate compile script to compile applets placed in the root applet directory.


<!-- Compile Java Applet classes here -->
<mkdir dir="${build.home}/applet"/>
<javac srcdir="${applet.home}"
destdir="${build.home}/applet"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}">
</javac>

You can see here that I am creating an applet directory below the build.home node, this will house all related applet stuff, keeping it nice and tidy and away from the other html and jsp files.

The compile script, compiled the applets and places them in this newly created directory.

Now we must copy other resource files that are required for the correct exaction of the applets.

<!-- Copy applet resources -->
<copy todir="${build.home}/applet">
<fileset dir="${applet.home}"
excludes="**/*.java"/>
</copy>

that’s it hay presto, when we run the dist (distrobution) script, the correct directory structor is created with docs and .war file ready for deployment in tomcat or other server.

<target name="dist" depends="compile,javadoc"
description="Create binary distribution">

<!-- Copy documentation subdirectories -->
<mkdir dir="${dist.home}/docs"/>
<copy todir="${dist.home}/docs">
<fileset dir="${docs.home}"/>
</copy>

<!-- Create application JAR file -->
<jar jarfile="${dist.home}/${app.name}-${app.version}.war"
basedir="${build.home}"/>

<!-- Copy additional files to ${dist.home} as necessary -->

</target>

The Applet tag used to load this appplet will be as follows…

<APPLET code="applet/ReadCodePicker.class"
archive="applet/mysql-connector-java-3.0.14-production-bin.jar"
width=600
height=75>
<param name='driverName' value="com.mysql.jdbc.Driver">
<param name='databaseName' value="xxxx">
<param name='userName' value="xxxxx">
<param name='password' value="xxxxx">
</APPLET>

SEE THIS FOR A GREAT TEMPLET
I hope this has been of use….
 
I would say that this solution is fine.

Thankyou for posting back a solution to your own question, it will hopefully help others. :)

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top