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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java applet which contains several classes

Status
Not open for further replies.

Rodie

Programmer
Jun 27, 2004
132
FR
Hi all !

I write a Java applet which is an application containing many classes in several folders (or packages). My problem is that only the startup class seem to work.

I mean the "main class" is launched at the launching of the applet, but all the classes it calls does not run.

I also would like to know if all the classes of the application have to extends the "Applet" class ...

Thanks if you have any idea :D
 
Maybe if you post the error you get we can offer some help.

One idea is that those classes must be in the classpath.

Cheers,

Dian
 
Hi Dian,

Thanks for ur reply. Actually I cannot have any error while executing. Indeed, my applet creates a socket to a server for communication.

If I open the socket from the "applet class" (I mean the class which is launched in the Web browser), I see that the server accept this connection.

But if I open the socket in another class (which is instantiate by the "applet class"), the server does not see anything. So the problem is that nothing happens.

And I know that if I execute my application as a Java application (not applet), all work well. So I think there is no problem of classpath. Am I wrong ?

Thanks again [dazed]
 
I'm stupid :(

I did not realize that apparently the HTML page download only the "applet class" specified in the <APPLET> tag and not all the source files. I have to use a JAR file, or something like that ...

That to you !! :D
 
To create a JAR file, I have to write this command line :
[blue]jar cf archive_name.jar files[/blue]

I tried to write this command in Windows cmd.exe (Programs->accessories->command prompt), but the "jar" keyword is unknown ...

I can't figure out if it's the proper place to write this. Where else ??

Thanks for your help !
 
You need to set your PATH environment variable to point to the bin directory in your JDK.

--------------------------------------------------
Free Database Connection Pooling Software
 
Humm, I've been "jaring" files from command line for years.

In the new era, isn't there any "winjar" tool that does that for you?

Cheers,

Dian
 
You don't need it - the file JAVA_HOME\bin\jar.exe is all you need.

--------------------------------------------------
Free Database Connection Pooling Software
 
It's weird because I have no jar.exe on my computer ...
I use Eclipse, and apparently with [red]jre1.5.0_02[/red]. There is a "bin" and a "lib" directory in it, but no jar.exe there. Is this normal ?
Thanks guys !
 
The jar.exe tool only comes with a JDK, not a JRE.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
If you only have a JRE then how the heck are you compiling code ? Eclipse must come with its own JDK.

Type this in DOS :

dir C:\jar.exe /s

and use that exe ... or download a JDK and install it.

--------------------------------------------------
Free Database Connection Pooling Software
 
Indeed, I have not jar.exe
Actually, I can create a jar file inside Eclipse. It works but it's not totally reliable (just read that on the Web)

If I download JDK, the pre-existing Eclipse I have won't work with it, but still with its JRE, right ? So I have to install a new Eclipse no ?

Thanks to you :D
 
I don't use Eclipse - so not really sure. I believe there is an Eclipse forum here somewhere.

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

Part and Inventory Search

Sponsor

Back
Top