4

Hi there I have a simple jar that works like a server, can I upload it to my OpenShift account and run it ? How by the way ? Thanks alot in advance.

TiagoM
  • 3,458
  • 4
  • 42
  • 83

2 Answers2

1

You might need to provide a few more details. If you want to upload a .jar file and have it run, you will need to add it to your git repository and then create an action hook that runs the .jar file (java -jar /path/to/file.jar &) and then do a git push. if you want to include the jar file for your .war web application to use, you can check the KB articles section of the openshift website for examples of how to do that.

  • Thanks for your reply. What I was trying to do was upload a .jar and run it. I already managed to push the jar to the openshift directory using git. And I also managed to put the jar running using ssh remote client (puTTY for instance) but my clients can't connect to the server, don't know why.. I get EOFException when I try to create a socket with the server socket (the one that is running on the openshift) – TiagoM Feb 17 '14 at 10:52
1

Only port 8080 on a specific IP is exposed to the outside world. Check the docs for the environment variables such as ${OPENSHIFT_DIY_IP} and ${OPENSHIFT_DIY_PORT}. (Note the public connect via port 80 but they are connecting to the openshift infrastructure which forwards to your app running on port 8080.)

An example of running a jetty server as a jar is given at https://stackoverflow.com/a/33114072/329496 which builds a WAR file then has a start script which runs jetty as a JAR assigning the host and port using those environment variables.

To be honest if you are building a JAR and pushing it to the server you could use just use Amazon Web Services to get a host without any added extras. OpenShift is PaaS (platform as a service) whereas Amazon Web Services is IaaS (infrastructure as service). If all you need is linux and java that is very well supported with any IaaS. They also have less restrictions on a raw linux virtual machine such as being able to run on port 80. As an example I used to build JARs to run on OpenShift but they don't have full support for websockets (you have to use a high port which is not acceptable to many corporate web proxies). So I moved over to AWS and it was very easy to get things running there.

Community
  • 1
  • 1
simbo1905
  • 6,321
  • 5
  • 58
  • 86
  • Even using a full VM may be too much; you can run a JAR in a hosted docker container https://en.wikipedia.org/wiki/Docker_(software). To see how easy it is to run a jar with Docker just take a quick look at this page which has a `src/main/docker/Dockerfile` that is all that is needed to boot a JAR file. Then if you google "docker hosting" you will see a huge amount of options to host apps. – simbo1905 Oct 18 '15 at 13:40