1

I have two java Swing applications and I need to be able to execute the first one from the second. I have compiled the first to a jar and placed it in the classpath of the second. I am calling the main class of the first jar from the application but all I see is a blank frame. The Main of my first Jar looks like this:

import java.awt.EventQueue;
import java.awt.Frame;
import javax.swing.JDialog;
public class AskulLibrary extends Frame implements Runnable{
final Frame frame;
    public AskulLibrary(Frame frame) {
        this.frame = frame;
    }

    public void run() {
        frame.show();
    }

    public static void main(String[] args) {
        JDialog.setDefaultLookAndFeelDecorated(true);
        // Throw a nice little title page up on the screen first
        new Splash().showSplash(3000);
        EventQueue.invokeLater(new AskulLibrary(new JLibrary()));
    }
}

I'm calling this main class from the second application like this:

import com.AskulLibrary;
import java.awt.Frame;
public class MainFrame extends JFrame{
       AskulLibrary lib;
       Frame frame;
     public MainFrame(){
    frame = new new Frame();
    lib = new AskulLibrary (frame);
    lib.run();

}

}

I'm doing something wrong somewhere because instead of initializing the first Jar I am getting an empty Frame. I do not want to run the jar like this although this is running the first program successfully:

Runtime.getRuntime().exec("java -jar lib/Myfirstjar.jar");
Montag451
  • 1,168
  • 3
  • 14
  • 30
Stanley Mungai
  • 4,044
  • 30
  • 100
  • 168
  • 1
    1) `frame = new new Frame();` That would not compile. For better help sooner, post an [SSCCE](http://sscce.org/). 2) Why AWT rather than Swing? See this answer on [Swing extras over AWT](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see [Mixing Heavyweight and Lightweight Components](http://www.oracle.com/technetwork/articles/java/mixing-components-433992.html). – Andrew Thompson Jun 11 '13 at 08:36

1 Answers1

2
Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319