Re: ShutDown from JButton
When you say doesn't work, what do you mean? Is there an exception? Please post any diagnostics you can (i.e. exception messages, stack traces, etc.)
1 Attachment(s)
Re: ShutDown from JButton
Quote:
Originally Posted by
helloworld922
When you say doesn't work, what do you mean? Is there an exception? Please post any diagnostics you can (i.e. exception messages, stack traces, etc.)
this is the exception
Attachment 1312
Re: ShutDown from JButton
It looks like a class-path error. Make sure all your base class paths get included (if there's more than one). What's the folder structure you have, and what command are you using to run from the command line?
Re: ShutDown from JButton
Quote:
Originally Posted by
helloworld922
It looks like a class-path error. Make sure all your base class paths get included (if there's more than one). What's the folder structure you have, and what command are you using to run from the command line?
I have two packages one is "rd" where is my "loginform.java" and the other is "classes" where is "sdown.java"
I run it from the cmd with this command java -jar "C:\Documents and Settings\Daniel Miovski\My Documents\NetBeansProjects\R D\dist\R_D.jar"
Re: ShutDown from JButton
Quote:
Originally Posted by
mija
I have two packages one is "rd" where is my "loginform.java" and the other is "classes" where is "sdown.java"
I run it from the cmd with this command java -jar "C:\Documents and Settings\Daniel Miovski\My Documents\NetBeansProjects\R D\dist\R_D.jar"
Well, I never use IDE to develop an app (I swear :cool:). Every good IDE takes care about the running process whether it's finishes or still in...waiting. That why your Shutdown class works within your IDE. If you run this class outside your "protected" IDE environment your class is lost. Why? Let analyse your code. The command Runtime.getRuntime().exec(shutdownCommand); is fired then the next command is executed....and it is an EXIT, your JVM terminates and your previous command is probably still in process. Remember Java JVM works asynchronously.
You have to remove the System.exit(0) and put it in the JButton method ShutDownBtnActionPerformed(...) or wait for the termination of the exec() execution.
For example:
My advice. IDE relieves a lot of writing work....but it fools its users, too. You learn more if you write your code without IDE (using any fine editor, for example the free editor Jedit of Sourceforge)
Re: ShutDown from JButton
Terminating the other process not the issue here. Rather, it's an exception being thrown before it starts the process. Processes created by the JVM continue to run even after the JVM shuts down.
@mija
You're two class file names must match the names of the classes. So sdown.java belongs to the class sdown, not to the class ShutDown. You must also make sure your jar file's folder structure follows your package structure.
Re: ShutDown from JButton
I SOLVED this problem by moving the class into the package
Thanks