Originally posted by Devasia Manuel: I am looking for a type of thread that does not need the JVM to run, such as if I start task manager and I end the javaw.exe process, my program should still run...
Are there any threads like that in java?
Well, once the JVM exits, all threads started by the JVM will be terminated also. So, when you say "does not need the JVM", you are talking about an external process, which you can start with a Runtime.exec() call.
Originally posted by Devasia Manuel: Im not quite sure what you mean, could you please give me an example??
Threads always run inside a process. Any java code always needs a jvm i.e. without a JVM you can not run any java code. So, if you want something to run without a jvm, it can not be a java code but an external non-java process. This is what Herny meant i.e. you need to start an external process that will continue to run even after the jvm exits. For example, if you have a shell script that keeps on polling a directory to look for new files. You want this script to start from a java program but still want it to continue after your java program exits. Then, you can start this script using Runtime.exec(). Irrespective of whether the java code that started this script is alive or not this script will continue to run.
In a nutshell,
There is no java thread that can run outside jvm but there can be a non-java thread that runs outside the jvm. You can start such threads using Runtime.exec()
What you want is the task manager for the OS. You can program it to start your application at times you choose. So if you have something that needs to be done at 2am every tuesday, you need to ask the OS to start your program at that time. Windows and Linux both have facilities for this.
Joined: May 13, 2008
Im not looking for the Runtime.exec() method since that only starts processes, I am looking for a way to execute a .jar file after the JVM has been shut down and that .jar file should still be running
As was pointed out above, a JVM is needed to execute a jar file. No JVM means no active Java process.
You can use Runtime.exec to start a second JVM that executes the jar file. Once that's up and running you can exit the first JVM. I think that would not terminate the second JVM; that's easy to find out, though. [ September 27, 2008: Message edited by: Ulf Dittmer ]
Ping & DNS - updated with new look and Ping home screen widget