Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-17-2012, 01:47 AM   #1
LQ Newbie
Registered: Jan 2012
Posts: 8

Rep: Reputation: Disabled
Question Program closes fine when run from cmd but .jar doesn't close.


I`m developing a simple java application and I've run into a rather annoying issue. When I run my application from the command line using > java Main it behaves as expected, specifically when I close the window the program exits gracefully. However when I build it as a jar using > jar cfe app.jar Main Main.class Form.class it doesn't do anything when I hit the close button and I have to kill the process.

The app simply displays a randomly selected message if the app hasn't been run earlier in the day.

This is my main method.
public static void main(String args[])
    String message = "";
    boolean usedToday = false;
    usedToday = usedToday();
    message = getMessage(usedToday);
And the form class
public class Form {
    public static void draw(String message) {
        final Frame frm = new Frame("App");
        Label lbl = new Label(message);
        frm.setSize(500, 200);
        frm.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {

Old 07-17-2012, 02:03 AM   #2
LQ Newbie
Registered: Jan 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
The solution was simply to include the class file Form$1.class in the jar
>jar cfe app.jar Main Main.class Form.class Form$1.class
>jar cfe app.jar Main *


close, jar, java

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
script doesn't run in cron (runs from shell just fine) Timur Sakayev Linux - Software 6 02-26-2007 12:56 PM
How to run JAR from within Java program ?! EAD Programming 1 12-31-2006 07:11 PM
How to run script that doesn't terminate when shell closes? bjdea1 Linux - General 2 09-20-2004 10:20 PM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-14-2003 11:18 PM
HLDS closes when I close telnet MarleyGPN Linux - General 1 04-26-2003 05:34 PM

All times are GMT -5. The time now is 07:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration