• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Echoserver.jar by Marty Hall beginner problem

 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
margaret gillon
Ranch Hand
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 335
6
Linux Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it... Thanks for the explanation about the manifest file and for the link.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic