About 61 results
Open links in new tab
  1. Terminating a Java Program - Stack Overflow

    Mar 17, 2014 · Calling System.exit(0) (or any other value for that matter) causes the Java virtual machine to exit, terminating the current process. The parameter you pass will be the return value that the java process will return to the operating system. You can make this call from anywhere in your program - and the result will always be the same - JVM ...

  2. How do I close a java application from the code

    Jun 29, 2012 · Sure I can see problems with using exit() as soon as we involve threads. But then returning from main solves these elegantly by not stopping the program or has the exact same problems if those are daemon threads. shutdownhooks + system.exit seem to me the simplest working solution to really exit a program reliably (the swing solution calls system.exit in the background afaik).

  3. How to quit a java app from within the program - Stack Overflow

    Jan 15, 2014 · According to oracle's Java 8 documentation: public static void exit(int status) Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination. This method calls the exit method in class Runtime. This method never returns normally.

  4. Terminate a console application in Java - Stack Overflow

    Aug 24, 2012 · Close a running program from java application. 2. Terminating a Program Using Java. 0. Java Command Prompt ...

  5. JFrame Exit on close Java - Stack Overflow

    Jan 24, 2014 · Pressing the close (X) button on your window causes the operating system to generate a close window event and send it to your Java application. The close window event is processed by the AWT event loop in your Java application which will exit the application in response to the event.

  6. How can we stop a running java process through Windows cmd?

    (on Windows OS without Service) Spring Boot start/stop sample. run.bat @ECHO OFF IF "%1"=="start" ( ECHO start your app name start "yourappname" java -jar -Dspring.profiles.active=prod yourappname-0.0.1.jar ) ELSE IF "%1"=="stop" ( ECHO stop your app name TASKKILL /FI "WINDOWTITLE eq yourappname" ) ELSE ( ECHO please, use "run.bat start" or "run.bat stop" ) pause

  7. How to close a Java Swing application from the code

    Oct 1, 2013 · Using EXIT_ON_CLOSE will forcibly terminate the application. If you need to take action before the program exits (such as saving working data), then you have to tap into the JVM event handlers instead of just using the normal swing event handlers. Both will "work", but the EXIT_ON_CLOSE will cause problems for more complex apps. –

  8. java - Running a method when closing the program ... - Stack …

    May 5, 2017 · Since you are using Swing. When you close your application (by pressing the close button), you could simply hide your frame. Run the method you would want which creates the file and then exit the Frame. This would result in a graceful exit. Should there be any errors/exceptions, you can log that into a separate file. Here is the code

  9. java - How to programmatically close a JFrame? - Stack Overflow

    "How to programmatically close a JFrame" - If the JFrame.EXIT_ON_CLOSE is not set, it will not close. Anyway, I was just pointing out that it might be needed to add to the answer, since jframe.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); won't actually close it by triggering this event despite the user normally being able to close the window on X even if DO_NOTHING_ON_CLOSE ...

  10. java - How to close a GUI when I push a JButton ... - Stack Overflow

    Dec 26, 2011 · JButton close = new JButton("Close"); close.addActionListener(this); public void actionPerformed(ActionEvent closing) { // getSource() checks for the source of clicked Button , compares with the name of button in which here is close .

Refresh