File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Echoserver.jar by Marty Hall beginner problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Echoserver.jar by Marty Hall beginner problem" Watch "Echoserver.jar by Marty Hall beginner problem" New topic
Author

Echoserver.jar by Marty Hall beginner problem

margaret gillon
Ranch Hand

Joined: Nov 12, 2008
Posts: 318
    
    6

I am trying to use Hall's echo server class by typing into terminal in the directory where the echoserver.jar sits.

sudo java -jar echoserver.jar

Error message: Invalid or corrupt jarfile echoserver.jar

I downloaded the echoserver.jar from
Chapter 19 downloads

Do I need to remake the .class files as package in netbeans and run them there instead of using the .jar?

I am using Ubuntu Linux 7.10, AMD 64, Netbeans 6.1, java version 1.7.0

Another beginner question: If I am running the echoserver.jar do I need to turn off tomcat?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

If you examine the contents of the JAR file you will see that it is not an executable JAR and cannot be run with the "java -jar" command:


Another beginner question: If I am running the echoserver.jar do I need to turn off tomcat?

If they are both configured to use the same port, yes (or change the EchoServer.java file to use a different port).


[How To Ask Questions On JavaRanch]
margaret gillon
Ranch Hand

Joined: Nov 12, 2008
Posts: 318
    
    6

If you examine the contents of the JAR file you will see that it is not an executable JAR and cannot be run with the "java -jar" command:


I see....if the jar has packages with .class files then it is executable.

I unpacked it, compiled, and am able to run the echoserver.class using an open port 8680. Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8964
    
    9

Originally posted by margaret gillon:
I see....if the jar has packages with .class files then it is executable.


Actually it is the manifest file which makes a JAR file executable. Have a look at the Java Tutorial on JAR Files for more.
margaret gillon
Ranch Hand

Joined: Nov 12, 2008
Posts: 318
    
    6

Got it... Thanks for the explanation about the manifest file and for the link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Echoserver.jar by Marty Hall beginner problem