tomcat/applet question...  
Author Message
Frances Del Rio





PostPosted: 2005-8-14 7:58:00 Top

java-programmer, tomcat/applet question... this is really weird, in tomcat/webapps/<appName>I have a jsp AND an
applet.. I'm using a package called smack for writing jabber clients
(http://www.jivesoftware.org/smack/), so:

in jsp:
<%@ page import="org.jivesoftware.smack.*"%>
no problems...

in applet:
import org.jivesoftware.smack.*;
when try to compile get told this package doesn't exist...

package is where all packages are supposed to be in Tomcat
(C:\tomcat\common\lib) and, again, the jsp has no problems with it, but
the applet, which is in exact same location as jsp, for some reason
can't find it..

(in applet am even getting en error (identifier expected) on
system.out.println()... don't know what to make of this..
this is line: System.out.println("test");...)

weird thing is, if I hide System.out.println() line get told package
smack doesn't exist.. if I don't hide System.out.println() line get
ONLY identifier-expected error on System.out.println() line..

would appreciate any help... thank you.. Frances
 
Tor Iver Wilhelmsen





PostPosted: 2005-8-14 15:50:00 Top

java-programmer >> tomcat/applet question... Frances Del Rio <email***@***.com> writes:

> package is where all packages are supposed to be in Tomcat
> (C:\tomcat\common\lib) and, again, the jsp has no problems with it,
> but the applet, which is in exact same location as jsp, for some
> reason can't find it..

Er, applets don't run on the server but in the browser; they do not
have access to the lib directory on the server. You need to build the
applets using a classpath, then include the classes so that the
browser can get them.

> this is line: System.out.println("test");...)

You cannot have code outside of code blocks, like methods; that error
is something you get if that statements is at the "top level" in the
sourcefile.

> weird thing is, if I hide System.out.println() line get told package
> smack doesn't exist.. if I don't hide System.out.println() line get
> ONLY identifier-expected error on System.out.println() line..

It's not weird it's a consequence of that being two different parts of
compilation: Syntax parsing and dependency checking.
 
Frances Del Rio





PostPosted: 2005-8-14 21:20:00 Top

java-programmer >> tomcat/applet question... Tor Iver Wilhelmsen wrote:
> Frances Del Rio <email***@***.com> writes:
>
>
>>package is where all packages are supposed to be in Tomcat
>>(C:\tomcat\common\lib) and, again, the jsp has no problems with it,
>>but the applet, which is in exact same location as jsp, for some
>>reason can't find it..
>
>
> Er, applets don't run on the server but in the browser; they do not
> have access to the lib directory on the server.

of course.. I hadn't thought of that... I found my error, as I
indicated in a follow-up to my own OP (had to tell javac the classpath
to that package..) this is all on my tomcat locally for now; but once I
put this applet up on my website it won't run on users' machines unless
this package gets somehow downloaded to their machines, right? (I mean
make it part of jre somehow, that downloads if users don't have jre in
their machines?) hmmm.... one more thing to think about...

you're right about System.out.println().. has to be inside a block, not
just in applets, but also in stand-alone's and servlets (just tried all
three...)

public class myApp {
System.out.println(" ");

no go....... :-o

ok, many thanks for yr help..

Frances