• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to compile and run my Networking Chat application  RSS feed

 
stelios papamichael
Ranch Hand
Posts: 93
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,i've been developing a networking chat application and i finally finished it and i am super pumped to try it out.However,i am not sure on how i should compile my application and run it since it has a server package that i created that has all the server-side coding and another one which has all the client-side coding.Both of these packages have a script that has a main method so i tried exporting the application 2 times using the ServerMain.java script which has the main method and the Login.java class that has the other main method.However,the login one works fine but needs the server to be running on the port 5478 to connect to it.I port forwarded that specific port, but when i try to open the Server.jar file nothing happens.Am i doing something wrong here?Do i need to compile and export my project differently?Sorry if this is very basic stuff but i am a begginer for sure in networking java programming . Hope we can figure out something out and thanks in advance!
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i try to open the Server.jar file nothing happens

How are you trying to debug the problem?  Try testing it locally using the localhost IP address
Open a command prompt window and enter:
java -jar THEJARFILENAME.jar
and see if there are any error messages on the console.
Be sure the server program has lots of print statements to show what the code is doing.
 
stelios papamichael
Ranch Hand
Posts: 93
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
when i try to open the Server.jar file nothing happens

How are you trying to debug the problem?  Try testing it locally using the localhost IP address
Open a command prompt window and enter:
java -jar THEJARFILENAME.jar
and see if there are any error messages on the console.
Be sure the server program has lots of print statements to show what the code is doing.


Nice, that did work when i run it on my pc but now another question emerges.How can i send the program to my friends and have them connect?
From what i know they need to portforward the port i am using 5478 and enter my ip address.If that's correct,what else do i need to send them and i just need to run the server file from my pc right?they should not have to do that.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I don't know how to configure your modem or firewall etc to allow other sites to access your server.
If the users of your client program have your IP address and the port to use, they should be able to connect to the server running on your PC.
 
Henry Wong
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

Agreed. If your client, which I am assuming is only using Socket class (and not the ServerSocket class), it should never need to configure anything like port forwarding. If it can get to the default gateway (which all networked machines should be configured for), then it should work.

So, if your server side is on a private network, then only you need to do it for your side.

Henry
 
stelios papamichael
Ranch Hand
Posts: 93
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:Sorry, I don't know how to configure your modem or firewall etc to allow other sites to access your server.
If the users of your client program have your IP address and the port to use, they should be able to connect to the server running on your PC.


Ok it did work i just had to restart my router so that the port opened ! However, one last question(i promise :P ) i connected from a laptop and the internet connection on that laptop is super super slow.I managed to connect it to my server but it could not receive messages from me and then disconnected, that's because of the internet connection right?
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to connect it to my server but it could not receive messages from me and then disconnected, 

Is the a correct rephrasing?
I managed to connect my slow laptop to my server but the server could not receive messages from the laptop and then the laptop disconnected.

Are there any messages in the consoles of the server or the client?  You may need to add some debug code to both server and client to trace what the code is doing to help you solve the problem.
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to connect it to my server but it could not receive messages from me and then disconnected, 

Is the a correct rephrasing?
I managed to connect my slow laptop to my server but the server could not receive messages from the laptop and then the laptop disconnected.

Are there any messages in the consoles of the server or the client?  You may need to add some debug code to both server and client to trace what the code is doing to help you solve the problem.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!