Ubuntu System Start-up: What command to insert to run java app? - java

In Ubuntu 10.10, System/Preferences/Startup Applications, I am trying to add a .jar program. If the program sits in home/john/this-folder/app.jar, what would I put in the command line for it to run on start-up?

java -jar /home/john/this-folder/app.jar [optional arg if any]
java - the Java application launcher

Note that you need to include jar in classpath if you java app needs dependecies.
You do that by:
java -jar /yourApp.jar -cp /home/zzz/libs/

Related

Adding Java jar as Ubuntu service

I am trying to add my java jar application to Ubuntu as service so that when the Ubuntu server is restarted I dont need to manually run the jar command to run my application. At present I have to run this cmd on the terminal
java -jar myapp.jar -conf conf.json.
I came accross this link which would have solved my problem but for some reason the service is not running when i run the service as described in that website.
http://www.jcgonzalez.com/ubuntu-16-java-service-wrapper-example
Can someone please help me!!
I think your bash script should have "nohup" like this:
nohup java -jar myapp.jar -conf conf.json &

Running JAVA Programs with additional -cp in ubuntu

I'm attempting to run CPUSIM under ubuntu 16.4
java -cp .:richtextfx-fat-0.6.10.jar:reactfx-2.0-MR.jar
-jar CPUSim-4.0.11.jar
Is the line the readme file says to enter in, when i try using that line the program fails. I'm not that versed with java or runtime stuff under ubuntu. I'm trying to run it in a terminal that's in the file directory where i unzipped the file.
Any tips on using -cp with java in a terminal?

Cannot execute Java Classes on OSX

I'm trying to execute a java build using commandline in OSX 10.10,
The command I'm using:
java -classpath ./bin;./libs/log4j-1.2.17.jar example.hello.Server localhost:80
I've got MAMP up and running on the classPath and java is in the same "classes" directory.
Terminal is showing all options that can be used with java and is not executing the file. The same happends when using -cp.
Thanks
You have a misplaced ; instead of : in your classpath string. Try:
java -classpath ./bin:./libs/log4j-1.2.17.jar example.hello.Server localhost:80
Remember on OSX (or any other Unix flavor system) path separator is : not ; as on Windows/DOS

How to Run a Java Project on Linux Without Using IDE

I am new to Java.
Basically, I developed a java projects which contains multiple Java packages inside Eclipse. The project runs OK on my desktop with a redhat Linux installed. However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. Therefore, it is impossible to run Eclipse on that server.
Is it possible to do that? If so, how can I move the entire project to that server including the input and output folders?
Thanks
In Eclipse use the "Export Runnable Jar" option. Highlight your project then click file->Export, choose Java, choose Runnable Jar file. Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class.
You will need to install the JRE on the machine you want to run it on. This can be done with the following command:
yum install java-1.6.0-openjdk*
Once you have java then it is simply a matter of executing your application. I would recommend using eclipse to compile your project to a jar and use the following command to execute it:
java -jar *JarFileName*.jar
Running Java is nothing to do with Eclipse . You can run your java program in linux machine by opening terminal .
Step1;- Set your JAVA_HOME in your bash profile .
Step2:- open terminal , go to the folder or package where your main program is present.
Step 3:- compile it using javac -cp lib.jar Filename.java
Step 4:- After compilation class file will be available , run it using java filename.java
Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available
http://eclipse.org/downloads/?osType=linux

Running java jars under linux

I created a jar file and want to run it on linux machine.
In win32 machine I'm using:
java -classpath myclass.jar;log4j-1.2.16.jar;mysql-connector-java-5.0.8-bin.jar;. com.name.myClass.MyClass
However, on linux its doesn't work? Any ideas how to do it?
Use : instead of ; to separate items in your classpath:
-classpath myclass.jar:log4j-1.2.16.jar:mysql-connector-java-5.0.8-bin.jar:.

Categories

Resources