• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem of Server-client connection  RSS feed

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys! I learn Java with "Head First Java" book. There are server and cleint classes like a "DailyAdviceClient.java" and "DailyAdviceServer.java".
Just I've edited it by my code for visualization and graphics. It runs on localhost.
But then I made JAR files for client and server. And after my runnig try it doesn't run.
I've used IntelliJ IDEA for it.
Could you help me please. Classes code is below. Thank you for your advices beforehand.

1. Client code:



2. Server code:

 
Marshal
Posts: 56608
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us the contents of the .jar, and the contents of its manifest file.
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:contents of the .jar, and the contents of its manifest file.







 
Campbell Ritchie
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post text; screenshots are very difficult to read. But even with the difficult reading, I can see a problem. You haven't got a main class named in the manifest file. Read the section in the Java™ Tutorials, particularly the part about an application's entry point.
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Please post text; screenshots are very difficult to read. But even with the difficult reading, I can see a problem. You haven't got a main class named in the manifest file. Read the section in the Java™ Tutorials, particularly the part about an application's entry point.


Contents of manifest files:

Manifest-Version: 1.0
Main-Class: Client.DailyAdviceClient

Manifest-Version: 1.0
Main-Class: Server.DailyAdviceServer


But it doesn't run.
 
Ranch Foreman
Posts: 3072
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Chun wrote:
Contents of manifest files:

Manifest-Version: 1.0
Main-Class: Client.DailyAdviceClient

Manifest-Version: 1.0
Main-Class: Server.DailyAdviceServer


But it doesn't run.


That says that you have two packages, Client and Server.
However the screenshot of your jar files shows that neither of the two classes are in a package...they both sit at the root level.
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both classes are in them packages.

 
Dave Tolls
Ranch Foreman
Posts: 3072
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at your screenshot for either of those jar files (forget the project).
There are no packages in them.
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Look at your screenshot for either of those jar files (forget the project).
There are no packages in them.


I added it but no changes.

 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Instead of showing us screenshots, can you just list what's in the jar file for us?

> jar tvf DailyAdviceClient.jar


Henry
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Instead of showing us screenshots, can you just list what's in the jar file for us?

> jar tvf DailyAdviceClient.jar


Henry


Content of Client.jar:

META-INF/MANIFEST.MF
DailyAdviceClient.java
META-INF/

Content of Server.jar:
META-INF/MANIFEST.MF
DailyAdviceServer.java
META-INF/
 
Dave Tolls
Ranch Foreman
Posts: 3072
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which (as with the screenshots) shows clearly that the files are not in packages in the jar file.
It also shows that they are .java files and not .class files, so they won't run.

I don't know how the Eclipse jarring stuff works offhand, so I can't give you the solution, but it looks to me like you haven't told it to jar up the correct bits.
 
Campbell Ritchie
Marshal
Posts: 56608
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Eclipse you have an option to export the project as a jar and in the process you can set a “Main” class.
 
Dave Tolls
Ranch Foreman
Posts: 3072
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, hang on, that's IntelliJ in those screenshots isn't it?

When I add an artifact and select an empty jar, I get the <Module name> compile output option to add in, over in Available Elements.
Your's should be under Head First Project I think.
 
Alex Chun
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Oh, hang on, that's IntelliJ in those screenshots isn't it?

When I add an artifact and select an empty jar, I get the <Module name> compile output option to add in, over in Available Elements.
Your's should be under Head First Project I think.


Ouch, Dave, exactly! You are my big boss!
Campbell, thank you very much again.

I added "'Head First Project' compile output" into "Output layout" (jar archive).

PS. How can I stop server now?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!