• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FTPclient by org.apache.commons hangup...

 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello comunity!! this is my firts post...

I have a rare problem with the FTPCliente component...

I'm programing a JApplet to connect FTP to one server.. and when declare the FTPCliente object .. the applet hangup.. no exception rise... no messages... nothing... execution never finish... i'm very very stuck...

My developed machine is: Windows XP, Apache 2.2.4, PHP 5.2.4, JDK 1.6.11, org.apache.commons 2.0

The dummy code:



This is the simple html test:



So... the applet never finish... no message write in screen... but If I comment the line "clienteFtp = new FTPClient();" the applet works fine and the message "OK, FTPCliente object created!" write ok...

Seem me a fool error.. but ... I don´t understand the problem??... Can a simple creating object hangup the execution of an applet??

Any idea??

Thanks very much!!

ps: Sorry for my bad english...

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Are there any error messages in the Java Console?
 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Welcome to JavaRanch.

Are there any error messages in the Java Console?


Oooop.. I´m fool!! I had Java Console hidden!! yes!! raised exception!!



mmm... seems compile problem??

I have the packets in one subdirectory... "libftp"

commons-net-ftp-2.0.jar
commons-net-2.0-sources.jar
commons-net-2.0-javadoc.jar
commons-net-2.0.jar

The root directory in this case is: C:\web\www\java
Then... packet directory is: C:\web\www\java\libftp

And my compile order is:

javac -classpath libftp\commons-net-2.0.jar;libftp\commons-net-2.0-javadoc.jar;libftp\commons-net-2.0-sources.jar;libftp\commons-net-ftp-2.0.jar ftptest1.java

This is the problem?? sorry If the problem is stupid... but the last time I write in Java was 7 year ago and now I'm novice.. again...

Thanks!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a compilation problem, it's a runtime problem.

The applet tag needs an archive attribute that points to the Commons Net jar file.
 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:It's not a compilation problem, it's a runtime problem.

The applet tag needs an archive attribute that points to the Commons Net jar file.


Then... what is the solution?... sorry.. I don´t know what is the "archive atribute" and the process to make this archive to point to Commons Net Jar... thanks!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start reading here: http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

It explains the archive attribute.
 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Start reading here: http://java.sun.com/docs/books/tutorial/deployment/applet/html.html

It explains the archive attribute.


Oh! ok ok!! thanks very much!! now I understand... and solved!!!

But... I read that browser make one connection for each file in "archive".. is better make JAR ... and now... a new problem...

My directory structure:

Root development C:\web\www\java\
Specific directory of proyect: C:\web\www\java\test
Files in specific directory of proyect (C:\web\www\java\test): ftptest1.class commons-net-ftp-2.0.jar

Now... ftptest1.class code is:



Compile orders:

C:\web\www\java\javac -classpath test\commons-net-ftp-2.0.jar test\ftptest1.java
C:\web\www\java\jar -cf ftptest1.jar test\ftptest1.class test\commons-net-ftp-2.0.jar

The html for testing in C:\web\www\java where ftptest1.jar is created:



Well... again a problem:



Damn!... where is the problem?? if the commons-net-ftp-2.0.jar and ftptest1.class are together in the same directory within the JAR archive... why ftptest1.class can´t find commons-net-ftp-2.0.jar??

I´m lost...

Any idea? thanks!!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not how jar files work. You can't keep one jar file inside of another one. Put both jar files side by side in the same directory, and then use
archive="ftptest1.jar, commons-net-ftp-2.0.jar "


I read that browser make one connection for each file in "archive".. is better make JAR

I don't understand this comment. What's supposed to be the problem with that?
 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:That's not how jar files work. You can't keep one jar file inside of another one. Put both jar files side by side in the same directory, and then use
archive="ftptest1.jar, commons-net-ftp-2.0.jar "



Ok!, I'm wrong, I believed that I can group all in one jar (class and another JAR)... obviously, I'm wrong , ok! problem resolved ;)

Ulf Dittmer wrote:
I read that browser make one connection for each file in "archive".. is better make JAR

I don't understand this comment. What's supposed to be the problem with that?


Sorry... again my bad english... I will try explain myself.

If I have 4 archives to download for execute locally like:

archive = "packet1.jar,packet2.jar,packet3.jar,packet4.jar"


I think the browser make one http petition for each archive (in this case 4 petition)... so... each petition mean the client browser must wait to server response to download the file.. right?.. if we have 4 files... need wait 4 times more... If we have only 1 archive only must wait the time of one connection... it's right?

Hope explain myself ;)

Dittmer, really... thanks for you support!! really thanks!!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the browser make one http petition for each archive (in this case 4 petition)... so... each petition mean the client browser must wait to server response to download the file.. right?.. if we have 4 files... need wait 4 times more... If we have only 1 archive only must wait the time of one connection...

Actually, in almost all cases only a single connection would be used, thanks to HTTP pipelining, so there's no overhead of multiple connections. Also, even if there were multiple connections to be opened and closed, the time to do that would be dwarfed by the time it takes to download the jar files themselves. So there's nothing wrong with having multiple jar files.
 
Alarico Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Dittmer!!

All clear now!!

I'm very grateful!! thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic