Start Java application at system start up linux/unix

Hi,
I am working on a application, which needs to run as a background process in linux/unix without the intervention of the user.
Please give me the details procedure how to make it as background process.
thanks

you can make any process a background process by adding an amperstand
for example:
java -cp $MyClassPath myAppClass &
If you want to run it automatically at startup
you'll have to write a little script which is executed at startup
and contains a line as above.
The scripts exectuted at startup are usually located at
/etc/init.d
You can use one of those scripts as starting point for your own script.

Similar Messages

  • Autostart java application at system start / logon

    Hello
    I wonder if there is a class dealing with autostart of programs?
    My problem:
    I'd like to have my application started when the user logs on the computer. The user shall be able to choose if he wants this (register autostart) or not (remove autostart) from within the java application.
    Further, the solution should work on Windows as well as on KDE, Gnome, ...
    (On windows a key in HKCU/Software/Microsoft/Windows/CurrentVersion/Run would have to be created, KDE needs a file in ~/.kde/Autostart)
    Is there such a class or approach; or am I on my own?
    Thanks!
    Christian Weiske

    no there can be no way to come up with a
    multiplatform solution, that's a platform-specific
    problemI thought if things like Preferences (files on *nix, registry on Windows) are available, a solution for autostart could be there :/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Sun Java Application Server 9 Start Up Woes

    Hi,
    I was asked to install the netbeans 5.5 IDE (which comes with Java Application Server 9 bundled with it) and basically learn how to develop using JMS. After installing everything and following the JavaEE tutorial, I began to set everything up. I get hung during the Sun Java Application Server 9 start up.
    It attempts to bind to my host name. After a week of research as to the cause, i discovered that the problem is that the server gets my host name from DNS and uses that as its bind location. The software running at my place of business prevents me from making connections such as these with anything but localhost connections.
    I descovered this when I read on here from another topic that i should try and start the server after disabling my network card. This method works in that the server starts up, no longer using my host name as the host but rather using localhost. Now this in no way fixes my problem.
    I was wondering if there were any workarounds that would force the application server or netbeans or whatever to use localhost isntead of doing a host name lookup?
    The error I got was a NoRouteToHostException, and when I disabled my network card that error went away, the error changed to UnknownHostException, but the server started up and I was then able to go to the admin page and deploy applications (but not run)
    P.S. I was going to post the output of the server start ups, but the size is crazy long, if you have a way for me to remove the stack trace I would be glad to give it a try.
    -SonOfThor
    Message was edited by:
    SonOfThor
    Linux Fedora Core, by the way.

    I switched to ActiveMQ and it works perfectly.
    The issue had to do with Netbeans, no matter how many config files i changed, always used my computername.host.com:8686 instead of localhost:8686.
    ActiveMQ starts and runs beautifully because it binds to localhost:8686.
    I dont know what the problem was, Ive read lots of solutions saying its firewall or a firewall like process. I'm running bare bones Linux Fedora Core with no extra programs. I insured my firewall was turned off before even posting this. I spoke with my IT guys and they said that the firewall thats set up here at work does not block port binds.
    My conclusion: IDEs are more of a pain then they want you to believe, im going back to terminal commands.

  • Start Java Application

    What is the best way to start java application without a dos window ?
    And to install it

    You can create an "executable JAR file" (a JAR file which has a MANIFEST.MF file in it with some special settings) or you can start your application with "javaw" instead of "java" to prevent the DOS window from opening.
    Jesper

  • Auto Start IChat program at System Start?

    Is there a way to automatically start IChat when the system starts? IE: Auto Login so I don't have to "Manually" start it each time?

    NOTE for some.
    It is worth noting that on some (Slower) Macs that, as the Start Up procedure actually connects to the Network quite late in the order of things, you may have problems.
    The Mac will in fact start to launch apps listed in the Login Items before the whole Start Up procedure has finished.
    This can mean if iChat is the only item or high on the list in Login Items that it can not find the Network and Log In before Start Up has finished.
    You may have to delete iChat from it's position in the list as it is not drag-able and re-enter it to have it later in the order of things.
    4:32 PM Sunday; March 29, 2009

  • Please package Java ME SDK 3.0 for Linux/Unix

    Hi Oracle guys!
    Please package Java ME SDK 3.0 for Linux/Unix soon!
    It would be of benefit both to us developers, and to Oracle.
    Thanks!

    user8771084 wrote:
    Señores Oracle si ustedes no pueden desarrollar Java ME SDK 3.0 for Linux/Unix no importa!!!, igual sabemos que no están a la altura de Sun Microsystems ni de la comunidad de Linux/GNU.
    Si ustedes se deciden lanzar la versión Java ME SDK 3.0 for Linux/Unix se lo agradeceremos, recuerde que Linux/GNU dia a dia crece mas y mas, y es un mercado que se debe cuidar.Translated to English:
    Oracle Gentlemen if you can not develop Java ME SDK 3.0 for Linux / Unix does not matter!,
    As we know are not up to Sun Microsystems or the community of Linux / GNU.
    If you decide to launch the Java ME SDK 3.0 for Linux / Unix appreciate it, remember that GNU / Linux is growing day by day more and more, and is a market that needs to be nurtured.

  • NW04S Java  application remians in "starting apps" phase.

    Dear all,
    I installed a java Application server voor a NWDI instance. However after stopping and starting the instance after what appeared to be a hung server. I am no longer able to logon via de Visual Administrator.The logon process runs to 99% then stalls.
    When I restart the Java application server both the SDM and the Dispatcher are started correctly. However the Server remains in the status Starting apps for hours.
    The following entry appears about every 10-15 minutes In the dev_server0 log: [Unloading class sun.reflect.GeneratedConstructorAccessor57]
    In the DefaultTrace.0.trc I get the follwoing entry:
    #1.5 #000BCD52CAAB000000000016000019800004387AB09D685F#1187999507111#System.err##System.err#######Thread[Thread-1,5,main]##0#0#Error##Plain###com.sap.engine.frame.core.configuration.ConfigurationLockedException: Cannot lock Configuration; it is already locked.
         at com.sap.engine.core.configuration.impl.ServerEnvironment.addLock(ServerEnvironment.java:316)
         at com.sap.engine.core.configuration.impl.ServerEnvironment.addLock(ServerEnvironment.java:340)
         at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.openConfiguration(ConfigurationCache.java:756)
         at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openConfiguration(ConfigurationHandlerImpl.java:734)
         at com.sap.engine.core.configuration.impl.ConfigurationHandlerImpl.openConfiguration(ConfigurationHandlerImpl.java:693)
         at com.sap.engine.core.cache.impl.spi.storage.DBStorage.<init>(DBStorage.java:64)
         at com.sap.engine.core.cache.impl.CacheManagerImpl.init(CacheManagerImpl.java:223)
         at com.sap.engine.core.Framework.loadSingleManager(Framework.java:577)
         at com.sap.engine.core.Framework.loadManagers(Framework.java:255)
         at com.sap.engine.core.Framework.start(Framework.java:189)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.boot.FrameThread.run(FrameThread.java:61)
         at java.lang.Thread.run(Thread.java:534)
    Caused by: com.sap.engine.frame.core.locking.LockException: Cannot lock [2007082501514709500000NLCC12045....................7395550, ! , 94d735ee/@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@, X]; it is in use by another owner. The lock collision occurred with user <internal>.
         at com.sap.engine.core.locking.impl3.LockingManagerImpl.lockInternal(LockingManagerImpl.java:257)
         at com.sap.engine.core.locking.AbstractLockingManagerImpl.lock(AbstractLockingManagerImpl.java:421)
         at com.sap.engine.core.locking.AbstractLockingManagerImpl.lock(AbstractLockingManagerImpl.java:441)
         at com.sap.engine.core.locking.ServerInternalLockingImpl.lock(ServerInternalLockingImpl.java:42)
         at com.sap.engine.core.configuration.impl.ServerEnvironment.addLock(ServerEnvironment.java:312)
         ... 15 more
    It looks as if the system is still holding a lock from a previous session, but I don't know how to release this.
    Can anyone me to resolve this issue.
    Many thanks,
    Owen.

    rkandy  
    If you had noticed correctly this question was posted and answered by me.
    The answer I posted here has also been confirmed by SAP.
    I posted the answer to help others who might face similar issues. There is therefore no need to add other solutions which may confuse other administrators who may have a real professional need to resolve similar problems.
    Furthermore I do not think that a SAP Technical Consultant would wait 4 hours before concluding that there might me something wrong with a Java installation which seem to hang the phase "starting apps".
    I am not asking for any points I just hope my answer will help others with similar problems.
    If anyone has been able to resolve similar issues on the basis of the solution provided here, then please update this message accordingly. Otherwise open an OSS message.
    Regards,
    Owen.

  • Start java application from java program

    My problem is the following:
    I start a java application A that allows you to select a couple of .java files.
    After having choosen them, the application adds some additional information to these .java files (that means some more lines of code � we call it �infecting� the java files).
    After the files have been infected, I want to start the application B implemented by these choosen and infected .java-files (without a new start of the Java Virtual Machine)
    For doing so, we use the following method whichs works quite fine:
    public static void ExecuteWithInvoke(String path, String classname)
         try
              new URLClassLoader(new URL[] {new File(path).toURL()})
                   .loadClass(classname).getMethod("main",
                   new Class[] { String[].class }).invoke(null,
                   new Object[] { new String[] {} });
         catch (Exception e)
         {e.printStackTrace();}
    The only problem that occurs:
    When the application B is launched, the �old� version of the choosen .java files is used and not the current, already infected version of these files. (I guess because the �old� .class files are used.)
    I solved this problem by finishing the program A after the infecting and restart my application B manually. In this case the infected .java files are used (I guess the new Start of the Java Virtual Machine solves my problem by reloading the �new� .class files)
    How can I reach to start my application with the mentioned method but with the infected .java files and without having a new start of the JVM ??
    Can anybody help me?
    Thanks in advance
    Sorry for my English, it�s a long time since I quit school

    Hello,
    my problem of reloading classes is still unsolved although you tried to help me!
    Therefore I posted a little program to illustrate our difficulty.
    It would be nice if somebody could have a look at this program.
    We have a file Testdatei.java whose only method is the main method.
    I get the class object of this file and with the help of Reflection the declared methods.
    Evereything works fine so far.
    Then I change the content of this file by adding an additional method a() (see change() for this).
    Now I delete the old class file and I compile Testdatei.java again (see compileJava()) and once more I get the class object for this changed file. Afterwards I get the declared methods for this class via reflection.
    But instead of showing now the methods main() and a() Reflection still only shows the method main().
    I guess the changed class has not been reloaded!!
    package testpackage;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.lang.reflect.Method;
    import java.net.URL;
    import java.net.URLClassLoader;
    import com.sun.tools.javac.Main;
    public class LoadClass
         private File f;
         private Class c = null;
         private Object o;
         public LoadClass()
              f = new File("C:/AAJ/src/testpackage/Testdatei.java");
              try
                   o = neuesExemplar(f.getPath(), "testpackage.Testdatei");
                   c = o.getClass();
                   System.out.println("Class " + c.getName() + " found.");
              catch (Exception e)
              {e.printStackTrace();}
              Method [] method = c.getDeclaredMethods();
              for (int i=0; i<method.length; i++)
                   System.out.println(method.getName());
              change();          
              compileJava(f.getPath());
              File fileToDelete = new File("bin/testpackage/Testdatei.class");
              System.out.println(fileToDelete.delete());
              Class cla = null;
              try
                   Object o = neuesExemplar(f.getPath(), "testpackage.Testdatei");
                   cla = o.getClass();
                   System.out.println("Class " + cla.getName() + " found.");
              catch (Exception e)
              {e.printStackTrace();}
              Method [] methods = cla.getDeclaredMethods();
              for (int i=0; i<methods.length; i++)
                   System.out.println(methods[i].getName());
         private int compileJava(String javaFile)
         String[] args = {"-d", "C:/AAJ/bin/", "-classpath", System.getProperty("java.class.path"), javaFile};
         return Main.compile(args);
         public static void main(String[] args)
              new LoadClass();
         private Object neuesExemplar(String pfad, String klassename) throws Exception
         URL url = new File(pfad).toURL();
         URLClassLoader cl = new URLClassLoader( new URL[]{ url });
         Class c = cl.loadClass(klassename);
         return c.newInstance();
         private void change()
              FileWriter fw;
              BufferedWriter bw;
              try
                   fw = new FileWriter(f);
                   bw = new BufferedWriter(fw);               
                   bw.write("package testpackage;");
                   bw.newLine();
                   bw.newLine();
                   bw.write("public class Testdatei");
                   bw.newLine();
                   bw.write("{");
                   bw.newLine();
                   bw.write("public static void main (String [] args)");
                   bw.newLine();
                   bw.write("{");
                   bw.write("System.out.println(4);");
                   bw.newLine();
                   bw.write("}");
                   bw.newLine();
                   bw.newLine();
                   bw.write("private void a ()");
                   bw.newLine();
                   bw.write("{");
                   bw.newLine();
                   bw.write("System.out.println(55);");
                   bw.newLine();
                   bw.write("}");
                   bw.newLine();
                   bw.write("}");
                   bw.close();
                   fw.close();               
              catch (IOException e)
              {e.printStackTrace();}                                             
    I�m using eclipse 3.1.0. Is it possible that it�s a bug in eclipse that eclipse holds the old class file in memory from the beginning and always refers to this one and not to the new compiled one?
    Thanks a lot
    Simon

  • Java application won't start anymore

    Hi,
    I am using a Java Application (Protege) that was running just fine last week but today it just won’t start!
    When click-on it jumps about 3 time in the dock and stop. I was able to run the connected .jar file but most of the features are not available this way.
    I have not done anything special since last week beside Safari update (1.3.2.).
    Any help is greatly appreciated.
    Regards,
    Adrien
    iBook G4 (1Ghz)   Mac OS X (10.3.9)  

    Did you update Quicktime to 7.0.4? See if the following discussion seems relevant. There's a solution in the fourth message (reverting to Quicktime 7.0.1).
    http://discussions.apple.com/thread.jspa?messageID=1500443
    If that's the fix, the problem may be due to Protege using an outdated JavaApplicationLauncher. See
    http://www.opensubscriber.com/message/[email protected]/3072264.html
    --Davipo
    iMac G5   Mac OS X (10.3.9)  

  • Start java application from jsp?

    is there any way i can have a JSP, bean or servlet start a java application on the server? maybe a better question is: what can i do to make sure that some class is always running on my javaserver? im talking about the server app. for a chat program that im making that will be an applet in a JSP page along with a load of other JSP pages that do other things...
    sorry for my incoherence. i usually talk better than this. :)
    Laz

    just replying so the message comes to the top of the forum... can anyone help me here?
    Thanks
    Laz

  • Failed to start  java application server  8

    hi every body,
    hi every body,
    i am getting the famous error:
    " failed to start sun java application server 8 possible causes:
    -port conflict
    -incorrect server configuration(domain.xml need to be corrected manually)
    -corrupted deployed application preventing server to start (domain.xml needs to be modified) "
    the thing is that i know the cause of error it is the 3rd one since i had some exception while running a project and since on this error was appearing,and i didnt know how to solve this problem i.e how to edit the domain.xml file
    so i uninstaled and reinstaled the java cretor a number of times every time i face the problem, but the last time i did so the folder C:\Sun\Creator\SunAppServer8\domain that contains the file domain.xml was not even there and i dont know why did that happen or how to solve it
    please help,
    regards.

    i too have a similar problem - mine seems to be related to MySQL access but I cant find any help on the problem - surely there is a better way than to continually re-install - on the previous version i could work it out without a re-install but not with the update.
    i havent found anything in the server logs - they are huge docs - i cant see how it can be a port conflict as its ok 1 minute and not the next.
    i just need a pointer to where to look ?
    thanks in advance

  • Starting Java application from other Java application..

    Hi all,
    I was wondering if it is possible to start a Java program from an other Java program.
    In Java program 1, I have this code to execute the other application:
    try {
        Process p = Runtime.getRuntime().exec("cmd /c java -cp JavaApp2.jar com.test.TestFrame");
    } catch (IOException e) {
    }I tried this code, but unfortunately I couldn't opened the other (JavaApp2.jar) Java Application. Is there a way to open the other application anyways?
    I really hope someone can help me. Help would be greatly appreciated! Thanks in advance.
    Tongue78.

    What if there is no JAR file?Then you can make it out of the .class files. And to anticipate your next question, if there are no .class files there is no application at all, so you can't exec() it or call the main() method directly. Your point?
    And JAR isn't part of the Java language.It is a major part of the Java platform.
    This means you can only get access to a JAR file via the OS. Wrong again. CLASSPATH. URLClassLoader.
    In short you cannot just shout main() in a Java program and hope some other Java program will hear you and start.Absolute rubbish. If the required classes are on the CLASSPATH you just call com.company2.app2.main(args) and off you go. Or you can load the main class and invoke its main() reflectively.
    No source code required, or 'source code merge' either.

  • Batch file to start java application

    Hi All,
    I have created a batch file to start my application.
    startApp.bat
    javaw myclass
    But now the problem is the command prompt is not closing. I want the command prompt to close automatically. Any help??
    Thanks in Advance,
    Manjinder Singh

    I cannot use double click on JAR file as i have some other commands also inside batch file. Like classpath setting etc.
    I tried to use cmd /c myapp inside batch file, but still the command prompts stays there till i exit my application.
    Any further HELP??

  • Cann't start Java Application

    Hi, my main class called TemplateUtil. I have created TemplateUtil.jar and try to start my application:
    javaw.exe -cp W:\eclipse\TemplateUtil\bin\de\qv\ec\servlets\util\TemplateUtil.jar;D:\jblibs\classes12.zip -Dfile.encoding=ISO8859_1 de.qv.ec.servlets.util.TemplateUtil.main
    Error: could not find main class.
    Why?

    That's what I was wondering.
    de.qv.ec.servlets.util.TemplateUtil.main
    Isn't this actually saying there is a subclass called "main" inside TemplateUtil.
    Shouldn't it just be:
    de.qv.ec.servlets.util.TemplateUtil ??
    I don't want to confuse the issue, but if someone could explain where de.qv.ec.servlets.util.TemplateUtil.main is valid let me know.

  • Apache Tomcat goes down on starting Java application, Oracle error

    Hello all
    I am running a Java application on Apache Tomcat 5.5. I use Oracle 10g Express Edition as the back-end for my application. I deploy my application using theTomcat manager and it works fine.
    However, when I try to access the home page of the application, my Tomcat server goes down. The stdout logs of Apache Tomcat display the following message:
    Exception message: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
    ORA-12705: Cannot access NLS data files or invalid environment specified.
    What could the possible reasons be for this to happen? And how can I workaround or fix this?
    Thanks
    Swetha

    This looks like a problem that XE has with some recently altered locales, i.e. Russian. You can work around the problem by making sure that the Java locale (Locale.setDefault()) is supported by XE before the JDBC connect call. For example, use Locale.setDefault( Locale.US ). After connect, you may explicitly set session NLS parameters using ALTER SESSION. You can also restore the Java locale.
    -- Sergiusz

Maybe you are looking for