dcsimg
How can I load applets and packages from different directories than the specified for htdocs?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, December 20, 2001 03:36 AM

I have posted this question as a reply to another answer... I´ve searched the FAQ but I couldn´t find a concense (excuse my english please) about this topic. My problem is the following, Say I have the following directory structure: /foo/classes/foopack /foo/classes/fooaplic /foo/fooaplichtm I have two classes: /foo/classes/foopack/pack1.class /foo/classes/fooaplic/aplic.class where aplic.class is a JApplet that must import pack1. then I have an html file: /foo/fooaplichtm/aplic.html My question is: 1) Can I import packages and   More>>

I have posted this question as a reply to another answer... I´ve
searched the FAQ but I couldn´t find a concense (excuse my english
please) about this topic. My problem is the following,

Say I have the following directory structure:



/foo/classes/foopack

/foo/classes/fooaplic

/foo/fooaplichtm



I have two classes:



/foo/classes/foopack/pack1.class

/foo/classes/fooaplic/aplic.class



where aplic.class is a JApplet that must import pack1.



then I have an html file:



/foo/fooaplichtm/aplic.html



My question is:

1) Can I import packages and load classes that are not located
under my directory hierarchy?


2) If it is possible, How should be the html code for the
aplic.html file in order to load the aplic.class file wich have to
import the pack1 file? how must be the import line in aplic.class?
(import pack.pack1;?) Wich directories must be included in the
classpath?





I hope somebody can help me with this stuff, because sicerely I
couldn´t do it. Next I write again my last question...

thanks a lot.



----------------------------------------



First, please excuse my short english.



Roman, I have a question yet:



If I have a package in a directory, say

(some directory in the CLASSPATH)/foo_pack/pack.jar, and have the
applet code in another directory say

(the same directory in the CLASSPATH)/foo_applet/myApplet.class,
and try to load it in the applet viewer with the line:




code="foo_applet.myApplet.class" width=170 height=150>



I get the next error in appletviewer:

--------------------------------

java.lang.NoClassDefFoundError: foo_applet/myApplet (wrong name: myApplet)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:486)

at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)

at
sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:142)

at java.lang.ClassLoader.loadClass(ClassLoader.java:297)

at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:108)

at java.lang.ClassLoader.loadClass(ClassLoader.java:253)

at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:366)

at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)

at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)

at sun.applet.AppletPanel.run(AppletPanel.java:293)

at java.lang.Thread.run(Thread.java:484)

--------------------------------



But if I try this line in the html:





I get the next error in appletviewer:

--------------------------------



java.lang.NoClassDefFoundError: foo_pack/pack1

at myApplet. (myApplet.java:11)

at java.lang.Class.newInstance0(Native Method)

at java.lang.Class.newInstance(Class.java:237)

at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)

at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)

at sun.applet.AppletPanel.run(AppletPanel.java:293)

at java.lang.Thread.run(Thread.java:484)

--------------------------------





where pack1 is a class included in the pack.jar file located at
foo_pack directory, wich I have included through the line



import foo_pack.pack1;



in the myApplet.java code.





After all this stuff, my question is:



1) How can I define two or more directories for the codebase
parameter of the APPLET tag?



or



2) How can I do to load the packages and the code for an applet,
located in different directories, at the same time?



Thanks if you answer, and again, excuse my short english and my
short java knowledge.



Pedro S.

   <<Less
About | Sitemap | Contact