importing external package into applet..

importing external package into applet..

Post by France » Tue, 16 Aug 2005 07:28:57


I'm trying to run an applet w/an external package that I have put in
C:\tomcat\common\lib; applet is in C:\tomcat\webapps\appName I import
package the usu. way (import org.jivesoftware.smack.*;) it compiles
fine; but when I try to run it in browser it won't run.. when I try to
run it in appletviewer I get these errors..

C:\tomcat\webapps\appName>appletviewer index.jsp
java.lang.NoClassDefFoundError: org/jivesoftware/smack/XMPPException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
at sun.applet.AppletPanel.run(AppletPanel.java:298)
at java.lang.Thread.run(Thread.java:534)
java.lang.NoClassDefFoundError: org/jivesoftware/smack/XMPPException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
at sun.applet.AppletPanel.run(AppletPanel.java:298)
at java.lang.Thread.run(Thread.java:534)


they have a section on importing packages into applets at sun
( http://www.yqcomputer.com/ ),
but it's only about importing packages in system API, nothing about
including external packages.. I would appreciate some help.. thank you..

Frances
 
 
 

importing external package into applet..

Post by Andrew Tho » Tue, 16 Aug 2005 10:36:03


URL?

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Federal Law Prohibits Changing The Channel
"Tell 'em a hooka smokin' caterpillar, has given you the call.." Jefferson
Airplane 'White Rabbit'

 
 
 

importing external package into applet..

Post by France » Tue, 16 Aug 2005 11:14:05


thank you Andrew, this is locally on my tomcat...

this is so complicated (for me at my stage of knowledge at any rate..)
that I don't know if I can even explain properly.. but here's a try: I
think I will have to put everything in one package, what I write and
package I got on line, put everything in same jar.. so downloaded
package w/src code, came w/ant builder, got ant builder working (a feat
in itself for me, don't get ant too well yet, and had tried many times
to figure out how to use it.. looked in build.xml and found it a bit
mind-boggling..)

so: called my own little applet I wrote (just one src code file for now)
'achat.java' put in same location where all other src code is for
package, then compiled and jarred everything successfully using ant, but
now applet won't run in browser, and get this error when try to run in
appletviewer:

java.lang.NoClassDefFoundError:
smack/classes/org/jivesoftware/smack/achat (wrong
name: org/jivesoftware/smack/achat)

paths:

applet:
C:\tomcat\webapps\chat\smack\classes\org\jivesoftware\smack\achat.java

jar:
C:\tomcat\webapps\chat\smack\smack.jar

index.jsp that calls applet:
C:\tomcat\webapps\chat

in index.jsp that calls applet:

<APPLET archive="smack/smack.jar"
CODE="smack/classes/org/jivesoftware/smack/achat.class" width=510
height=110>
</applet>

why does it say 'wrong name' for applet?

would appreciate your help here inmensely..
I'm just getting started w/a project here and before I get all
elementals working can't develop any further..

Frances
 
 
 

importing external package into applet..

Post by Andrew Tho » Tue, 16 Aug 2005 11:24:59


A web page often describes it far better and more completely
that words.

Where are you going to be uploading the page too, once it
is complete and working? Didn't you manage to establish a
free Java server (or do I recall that wrong)?

In any case, ensure you are using the 'archive' attribute
to specify your external jars..
< http://www.yqcomputer.com/ ;

HTH

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Now With Chucklelin
"When you believe in things that you don't understand, you suffer.
Superstition ain't the way" Stevie Wonder 'Superstitious'
 
 
 

importing external package into applet..

Post by France » Tue, 16 Aug 2005 12:11:13


once again thank you Andrew.. so I have to use CODEBASE if applet
(.class file) is in diff. directory from html file referencing it.. so
this is applet tag I have now:

<APPLET archive="smack/smack.jar" CODE="achat.class"
codebase="classes/org/jivesoftware/smack" width=510 height=400>
</applet>

now get this error if I try to run in appletviewer:

C:\tomcat\webapps\chat>appletviewer index.jsp
java.lang.NoClassDefFoundError: org/jivesoftware/smack/XMPPException
at java.lang.Class.getDeclaredConstructors0(Native Method)
... etc..
java.lang.NoClassDefFoundError: achat (wrong name:
org/jivesoftware/smack/achat)
at java.lang.ClassLoader.defineClass0(Native Method)
.. etc..


XMPPException.class is there, where all other classes are, I see it..
and it's still telling me applet name is wrong.. I don't get this...

(this will go in my own site, www.francesdelrio.com (no, hosting is not
free, by any means......;) a hosting w/Tomcat and mysql and unix shell
and all that I don't think you can get for free.. although I could be
wrong, of course...) gotta go now, will have to continue w/this
tomorrow... thank you again, Andrew.. Frances
 
 
 

importing external package into applet..

Post by Andrew Tho » Tue, 16 Aug 2005 12:47:04


..

Yes and no. You have to specify where the classes are if
they are not obtainable from the CODEBASE. The CODEBASE
might default to the HTML directory, but it can be set to
other places using the CODEBASE attribute of the applet element.


You need to set the 'codebase' to the root or default package
above the class. If your class is org.jivesoftware.smack.XMPPException,
your codebase would be "classes", not "classes/org/jivesoftware/smack"

But! The codebase is usually used to specify the path to the
applet class. Then you add *ARCHIVES* to the 'archives' attribute.

I am thinking the 'org.jivesoftware.smack.XMPPException' class is a
class required *by* the applet which is itself on a different path?

In that case, the codebase should point to the applet, and
the classes of org.jivesoftware.smack.XMPPException and friends should
be in a .jar *archive* mentioned in the 'archives element'.


You (if I recall correctly) are still trying to debug
applet problems from inside JSP files. This is silly.
Prepare an HTML file that refers to the applet. If you
cannot get it to work in an HTML, it will not work in
JSP, and JSP simply adds more complications to the mix.

Further, whereas it can be tricky finding a free .JSP host,
free HTML sots are a dime a dozen. If you prepare an HTML
document that breaks, and upload it and all the classes to
a free site, it is much easier for others to see what is
happening.

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"At least you won't have time to be bored.." Midnight Oil 'Power & The
Passion'
 
 
 

importing external package into applet..

Post by Frances De » Tue, 16 Aug 2005 23:07:55

ndrew Thompson wrote:


oh man, I don't get this.. how complicated can it be to specify path to
an applet? I looked at contents of jar, contents are:

org/jivesoftware/
org/jivesoftware/smack/
org/jivesoftware/smack/AccountManager.class
org/jivesoftware/smack/achat.class // my applet
org/jivesoftware/smack/Chat.class
org/jivesoftware/smack/ConnectionEstablishedListener.class
org/jivesoftware/smack/ConnectionListener.class

....

org/jivesoftware/smack/util/StringUtils.class
org/jivesoftware/smack/util/WriterListener.class
org/jivesoftware/smack/XMPPConnection.class
org/jivesoftware/smack/XMPPException.class


so:
<APPLET archive="smack/smack.jar" CODE="achat.class"
codebase="smack/org/jivesoftware/smack" width=510 height=400>
</applet>

also tried these..
<APPLET archive="smack.jar" CODE="org/jivesoftware/smack/achat.class"
codebase="org/jivesoftware/smack" width=510 height=400>
</applet>

<APPLET archive="smack.jar" CODE="org/jivesoftware/smack/achat.class"
codebase="smack/org/jivesoftware/smack" width=510 height=400>
</applet>

<APPLET archive="smack/smack.jar" CODE="achat.class"
codebase="smack/org/jivesoftware/smack/achat.class" width=510 height=400>
</applet>

but none of them work... I mean what other ways are there to do this?
this is absurd... :(

(this HAS to be in a jsp.. will eventually use for a project at work
and it totally has to be in a jsp... this jsp is very simple for the
moment, all it contains is <applet> tag... I have tons of webapps in
my webhosting (jsp's and servlets..) am seriously learning java server
programmig and mysql, so obviously need Tomcat hosting..)

this one works fine..
http://www.francesdelrio.com/chat/pal.jsp
(no jar involved.. only difference...)
it's the one you helped me out with earlier..

(remember..
<%
if (ipt != null) out.print("<param name='color' value='" + ipt + "'>");
%>
..)

and fact that it's in a jsp has never been an issue..
(present problem sole issue is jar, am convinced..)
again, Andrew thank you very much.. Frances


 
 
 

importing external package into applet..

Post by Andrew Tho » Wed, 17 Aug 2005 00:06:08


...

Not when debugging an applet. I thought I had
managed to convince you of the benefit of separating
JSP/(D)HTML/Applet problems into the simplest elements,
but it seems not. :-(


(shakes head sadly) Why do you present that page
without validating it?
< http://www.yqcomputer.com/ ;
(I stress validation in that post, but your page shows 5 errors)


..yeah. I remember that.


(mouth drops) I cannot believe you would say that after
this thread (the same one in which I made the above post).
< http://www.yqcomputer.com/ #ea352f8a857d5b38>


..right.


Put up a valid HTML page referring to the applet
classe/s jar/s (whatever) and I will help you further.

--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Power and priviledge cannot move a people, who know where they stand, and
stand in the law." Paul Kelly 'From Little Things, Big Things Grow'
 
 
 

importing external package into applet..

Post by Frances De » Wed, 17 Aug 2005 02:43:56


ok, fair enough... http://www.yqcomputer.com/

this html file is in tomcat/webapps/chat/index.html
package in tomcat/webapps/chat/smack/smack.jar
applet in smack/org/jivesoftware/smack/achat.class

have three tags in there now, none of which are working:

<APPLET archive="smack/smack.jar" CODE="achat.class"
codebase="smack/org/jivesoftware/smack" width=510 height=100>
</applet>
<br><br>

<APPLET archive="smack.jar" CODE="org/jivesoftware/smack/achat.class"
codebase="smack/org/jivesoftware/smack" width=510 height=100>
</applet>
<br><br>

<APPLET archive="smack/smack.jar" CODE="achat.class"
codebase="smack/org/jivesoftware/smack/achat.class" width=510 height=100>
</applet>
<br><br>

thank you very much for any help, Andrew...
 
 
 

importing external package into applet..

Post by Oliver Won » Fri, 09 Sep 2005 06:53:34


I actually recommend you put only one instance of your applet there,
instead of 3. Otherwise the Java Console gets cluttered with error messages
and I don't know which message goes with which applet.

- Oliver