The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Maybe it's too late, maybe it's not want you want, but...

Posted by Gabriel on July 27, 2001 at 10:17 AM

> Hey,
> Can anyone tell me, how to Start a Windows EXE-File from a Java-Applikation for example by pressing a button in the Java-Apllikation.
> Please mail, if u have the answer.
> Thanx

try with native method and use c++;

in cpp


in Program.java

static
{
System.loadLibrary("Program");
}

public native void myBrowse();


on event:
myBrowse();

and then you need an cpp header file:
try: javah -jni Program.java


in c++ copy the header method somethink like that;

#include "Program.h"

JNIEXPORT void JNICALL Java_Program_myBrowse(JNIEnv *env, jobject canvas)
{
ShellExecute(NULL,"open","http://www.ipdevel.ro","",".",SW_SHOWMAXIMIZED);
}

and make an dll
cl -Id:\jdk1.3\include -Id:\jdk1.3\include\win32 -LD Program.cpp -Fe Program.dll -link D:\jdk1.3\jre\lib\jawt.lib
and another lib

now run java aplication java Program



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us