Re: How to make standalone Java applications?
mromarkhan_at_rogers.com
Date: 04/29/04
- Next message: Marte Brenne: "Re: Hypertext in java"
- Previous message: Thierry: "Re: bean and exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Apr 2004 13:04:52 GMT
Peace be unto you.
Here is a cheap hack
// http://www-106.ibm.com/developerworks/java/library/j-jniexe/jniexe.html
#include <windows.h>
#define MAIN_CLASS "Console"
int main(int argc, char** argv)
{
char * cmdline = (char *) malloc( 1024 ); /* big buffer */
wsprintf( cmdline, "javaw.exe %s", MAIN_CLASS );
for(int i = 1;i < argc;i++)
{
strcat(cmdline, " ");
strcat(cmdline, argv[i]);
}
system( cmdline );
return 0;
}
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Console extends JFrame
{
private JTextArea textdisplay;
public Console(String [] args)
{
textdisplay = new JTextArea();
this.getContentPane().add(new JScrollPane(textdisplay),BorderLayout.CENTER);
this.setSize(512,342);
this.setVisible(true);
for(int i = 0;i < args.length;i++)
{
textdisplay.append(i+" "+args[i]+"\n");
}
}
public static void main(String [] args)
{
Console console = new Console(args);
}
}
g++ myapp.cpp -o myapp.exe
Good bye.
- Next message: Marte Brenne: "Re: Hypertext in java"
- Previous message: Thierry: "Re: bean and exception"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|