3

I have a simple java chat application (server code + client code) which uses java's socket API to communicate with each other.This application is pure java SE and does not use any servlets or JSPs. Client is a desktop java swing application. I tested my code within localhost, and it works fine.

My question is about deploying this server code on the internet. If I had a personal server (with a static IP ) I could deploy the server code on it and configure it to communicate via the predefined port number in my code. The problem is I don't have one.

Now is there anyway that I could find such a service on the internet to host my code there and to configure it to communicate via my custom port? Or else is there anyway I could tweak my code a little bit, and make it work with an existing service closer to what I am expecting.

EDIT

I have managed to do this via Amazon EC2 virtual servers as pointed out in the answers

DesirePRG
  • 6,122
  • 15
  • 69
  • 114
  • 1
    which port is it running on and have you heard of openshift? https://www.openshift.com/ – Travis Sharp Apr 15 '15 at 16:51
  • I'm using a random port number (like 4222). no i haven't heard of openshift. i will check – DesirePRG Apr 15 '15 at 16:53
  • 1
    Openshift is pretty much Java web-app hosting for free (up to 3 cartridges) and if you switch that port to a standard one you can use that service if not you'll need to use some cloud hosted server. Amazon EC2 is an option or Azure but those can be quite expensive. Since it's java based you could probably pick up a small VPS server for ~$5-$10/month depending on your server needs. – Travis Sharp Apr 15 '15 at 16:55

1 Answers1

4

At least Amazon AWS has a free tier for EC2 with a single micro-instance and 750 hours of monthly runtime, see here: http://aws.amazon.com/free/

esaj
  • 15,875
  • 5
  • 38
  • 52
  • Will I get an IP address unique to me? can i use it as if it was my personal server? – DesirePRG Apr 15 '15 at 17:05
  • @DesirePRG: I haven't used AWS for a while, but at least before the machines would get unique public IP addresses out-of-the-box, see here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#public-ip-addresses – esaj Apr 15 '15 at 17:09
  • I managed to launch an EC2 instance and I was able to run my app perfectly. but I ran the server code through ssh in my machine, and when I close my shell the server code stops running. any work around? – DesirePRG Apr 15 '15 at 18:29
  • @DesirePRG: you could for example run it inside a GNU Screen (https://www.gnu.org/software/screen/, quick cheatsheet: http://aperiodic.net/screen/quick_reference ), also check this for other options: http://stackoverflow.com/questions/285015/linux-prevent-a-background-process-from-being-stopped-after-closing-ssh-client?rq=1 – esaj Apr 15 '15 at 18:49