[java] Swig in Windows applications?

Started by
20 comments, last by ARCHIGAMER 23 years, 9 months ago
No, no, javaw is exactly the same command as java, but it doesn''t output anything to the command line. It''s like running the java application in the background.
I am a Jedi, like my father before me
Advertisement
Archigamer, extending Applet or JApplet is only required to run as an applet in a browser. Any compiled java class that implements the main method can be executed as an application using java.exe or javaw.exe, the two runtime virtual machines provided by Sun. java.exe uses the command window(DOS prompt) it is run from for input and output, it also creates a new one if it is run from a shortcut, registry entry, etc... javaw.exe does not use a command window at all, so it appears to run ''in the background''. These can be run from a command line, or from a batch file, registry entry, etc... I am assuming you are using a Windows environment. Unix is a little different, and I''ll give you Unix specifics if you want.

Try compiling this class:

import javax.swing.*;public class MyApp extends Object{  public static void main(String args[]){    System.out.println("Before");    JFrame jf = new JFrame("My Window");      jf.addWindowListener (new java.awt.event.WindowAdapter () {        public void windowClosing (java.awt.event.WindowEvent evt) {          System.exit(0);        }      });    jf.show();    System.out.println("After");  }} 


Create two windows shortcuts that set the working directory to where this compiled class is. Then set each to use a different command line:

One should use this:
java -cp . MyApp

The other:
javaw -cp . MyApp

you may have to modify these to use full path names, (IE "C:\jdk1.2\bin\java -cp . MyApp") if your jdk/bin directory is not listed in your PATH environment variable.

Both start up a VM and run the class as an application. java.exe will create a command window, javaw.exe will not.
You should notice that this class has nothing to do with applets or a browser. This is run as an application, much the way Forte is run.

SteveMeister did read the post and is giving you good advice, there seems to be an impedence mismatch. I think this code snippet should straighten everything out.

ManaSink

This topic is closed to new replies.

Advertisement