1

I have a small java project that handle connections. In order to run it from the terminal I have to cd into the folder that contains the source and run the following command:

java -cp classes com.packagename.mainclass

Where classes is the folder that contains the classes.

I want ubuntu to run this application on startup, is there a Java command I can use? Or am I just better off creating a shell script?

Thanks!

1 Answer 1

0

On system boot:

Add to the end of /etc/rc.local:

(cd ~your_username/path_to_source/ && sudo -u your_username java -cp ...) &

(It might be better to create an Upstart job instead.)

On logon:

Open "System - Preferences - Startup Programs" (gnome-session-preferences) and add your program there.

2
  • Can you add a java program to Startup programs, I assume it needs to be compiled to a JAR first? Apr 28, 2011 at 13:52
  • @Christopher: But you can add the java command. Apr 28, 2011 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .