how to run java application on aws instance using command line - java

I now have a java program and amazon instance provided with a key..
Used to run java on aws programmatically, but now all I need to do is, use this instance, powerful.. to run my java application, but how.?
Should I make my java program a .jar and upload on the instance?
And documents about the command needed?
Thanks.

You upload a file to your EC2 instance with scp:
scp your.jar root#your.ec2:/tmp
You run your file with ssh:
ssh your.ec2 "java -jar /tmp/your.jar"
All that can be easily automated since no passwords are required to execute scp or ssh, you'll just need to exchange certificates.
Or did you mean that you wanted to make Java program part of your image?

If your Java application is web based, I would encourage you to have a look at Amazon's Elastic Beanstalk
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html
This service allows you to quickly deploy and manage applications to the cloud without worrying about the underlying infrastructure.
See more at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html
Seb

Related

How to create an exe file for a Java application which uses Mysql

I have developed a desktop application in java using netbeans and Mysql as my DB.
How can I create an .exe file including the database so that it that my application could be executed on other device?
Starting with MadProgrammer's quote:
AFAIK MySQL is database server, meaning it doesn't operate in
standalone mode. This would mean that you would need to install MySQL
on your target machine - which kind of seems counterintuitive. If you
want a standalone database, then maybe h2 would be a better
alternative, it's a pure Java SQL database system, which doesn't
require any additional installation
The simplest option is to use an internal DB, so that every resources will be bundled into a single application.
Otherwise - How can handle the external DB related issue (it being an application running alongside your java application)?
By creating a dedicated installation flow (running dedicated scripts which will install required 3rd party solutions prior to allowing your application to be executed):
Install the DB of your choice.
Optionally allow initial configurations to be aplied to the DB.
Install your own application.
Finalize the binding between the DB and your application.
Configure the OS to optionally run the installed DB on startup.
As for having an .exe executable for your java application - see the references I have provided. A 3rd party tool should easily create a .exe that will suite your needs.
A batch file which encapsulates the java -jar ... command can also work.
References:
Convert Java to EXE
How do I create an .exe for a Java Program?

Can Java Web Start be used to run server-side programs?

I have a Java application that needs to run the proprietary software PowerWorld on the server and then return output to the client side Web Start window. Is this possible? How do I go about doing this?
I am using Apache Tomcat to run the server. My Java code uses Runtime.exec() to run a Python script that runs PowerWorld. I made sure that the python script, powerworld file and java app are all in the same directory and reference each other using relative file paths
Java WebStart will install a desktop application into the cache of the client. That will run on the client not on the server, however you can easily create a webapplication as a service, i.e. on Tomcat. The webapp will be able to receive client requests, i.e. via RMI, RESTfull service or webservice, call the proprietary programm and return the results.

Run a simple Java program in the OpenShift cloud

what is the easiest method to run a Java program inside a gear on OpenShift?
I don't need a complex framework or web server. I just need a container to which I can upload my Java Files, compile and execute them in the cloud. The application I have in mind is very simple, a program that gathers some information and that I can connect to via RMI and just ask for the data.
Thanks.
If you don't need an application server you'd better take a look at DIY cartridge. You'd just have to create it from your code:
rhc app-create yourapp diy-0.1 --from-code git://github.com/(...).git
You could even use git hooks to launch it. Take a look at the hooks I use at my Wedding Tables Planner web, based in this template.
I think easiest is tu run a jbossas app and stop the jbossas cart if necessary. Otherwise you may play with the diy app type.

Call to remote JVM using cmd script

I need to call a jar which is kept on a shared windows machine.
The JVM also needs to be placed on this shared machine so that anyone with access to the remote location should be able to call this jar.
I need to write a windows script which shall be run using a service user.
Is this possible? If yes, request you to please provide pointers.
Java Management Extensions provides the tools for building Web-based, distributed, dynamic and modular solutions for managing and monitoring devices, applications, and service-driven networks.
see JMX Tutorial
see example with Linux script
see Windows cmd script
You might have some luck using the Tanuki Software Java Service Wrapper. Jetty uses this for their Windows Service Wrapper.
Another option is Apache Commons Procrun, which is what Apache Tomcat uses.
Both work well to set up a Java application as a Windows service. You will need to ensure your application is designed to run well as a service; you should be able to "trigger" events (start, stop, restart, etc.). You might need a lightweight adapter around the application to get it to work right as a service; but that should be a trivial exercise.
Once you have a service set up, make sure appropriate user(s) have rights to start/stop the service [1] [2]. You could even set the service up to run using a specific account. Then you can use the net start, net stop, etc. commands in a batch file.

Mount Java app inside cucumber rails app

I have a rails app that talks to an api running on the same domain via ajax calls. I want to test this app using cucumber. The api is written in java and packaged as a jar. How can I mount the jar when using cucumber?
There is no way to do it automatically but you can add Before hook into env.rb or put it into separate file and in this method you can load your java extension by issuing shell command, you can store process pid in variable and kill this process in After callbalk. You can configure Capybara to start server on specific port and I think you can tune your application to use specific port too.

Categories