Article View: comp.lang.java.programmer
Article #455Re: native exe-files with jbuilder???
From: Will Wood
Date: Fri, 10 Oct 1997 00:00
Date: Fri, 10 Oct 1997 00:00
95 lines
3430 bytes
3430 bytes
Andrew Bennett <abennett@borland.com> wrote in article
<3432e5bf.68854036@forums.borland.com>...
> On Thu, 02 Oct 1997 00:09:50 +0100, Sven Kirmess
> <sven.kirmess@earthling.net> wrote:
>
> >Can you create native x86 exe-files with the Borland JBuilder? If it is
> >possible, can you it with the basic edition?
>
> No, not with 1.0.
>
>
>
> Andrew
> --
> Andrew Bennett -> abennett@borland.com
> JBuilder info -> http://www.borland.com/jbuilder/
> JBuilder newsgroups info -> http://www.borland.com/newsgroups/
> **** Please don't post a reply AND send email. Do one. I'll see it.
****
>
You can actually build this yourself with a C++ (or Ansi C) Compiler.
Here's some source that does it!
//
// Demonstrates how to build a stand alone Java Executable
//
// When Started this program does the same thing as the JDK\bin program
// rmiregistry.
//
// Will Wood <wkwood@burgoyne.com>
//
#include <stdlib.h>
#include <jni.h>
JavaVM *jvm;
JNIEnv *env;
JDK1_1InitArgs vm_args;
int main(int argc,char *argv[])
{
jclass c,stringClass;
jmethodID mainMethod;
jarray strings = NULL;
int i;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
vm_args.classpath="d:\\jdk1.1.4\\lib\\classes.zip"; // use your own
classpath
JNI_CreateJavaVM(&jvm, &env, &vm_args); // load up the VM
stringClass = (*env)->FindClass(env,"java/lang/String"); // we need a
java.lang.String handle
if(argc > 1) // if we have args
{
strings = (*env)->NewObjectArray(env,argc - 1, stringClass, NULL); //
construct array
for(i = 1;i < argc;i++)
{
jstring argument = (*env)->NewStringUTF(env, argv[i]); // allocate a
string
(*env)->SetObjectArrayElement(env,strings,i - 1, argument); // put it
into the array
}
} else
{
strings = stringClass = (*env)->NewObjectArray(env, 0, stringClass,
NULL); // allocate 0 len array
}
c = (*env)->FindClass(env,"sun/rmi/registry/RegistryImpl"); // find the
main class
mainMethod = (*env)->GetStaticMethodID(env, c, "main",
"([Ljava/lang/String;)V"); // and method
(*env)->CallStaticVoidMethod(env, c, mainMethod, strings); // and start it
up..
(*jvm)->DestroyJavaVM(jvm); // terminate the VM..
return 1;
}
You'll have to include the jdk\include and jdk\include\platform (e.g.
WIN32) when compiling and
include the javai.lib (normal) or javai_g.lib (debug).
This is actually how I implement a native look and feel application for
products that I build.
Technical Details
Message-ID:
<01bcd534$80fa6340$0cb29dcc@wwood-home>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3432D83E.5D6C2CF4@earthling.net> <3432e5bf.68854036@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10a146,36ee4980906152ed X-Google-Attributes: gid10a146,public X-Google-Thread: fa3e3,36ee4980906152ed X-Google-Attributes: gidfa3e3,public X-Google-Thread: 1089d0,36ee4980906152ed X-Google-Attributes: gid1089d0,public X-Google-Thread: fecd1,36ee4980906152ed X-Google-Attributes: gidfecd1,public X-Google-Thread: f74b3,36ee4980906152ed X-Google-Attributes: gidf74b3,public From: "Will Wood" <wkwood@burgoyne.com> Subject: Re: native exe-files with jbuilder??? Date: 1997/10/10 Message-ID: <01bcd534$80fa6340$0cb29dcc@wwood-home> X-Deja-AN: 279162998 References: <3432D83E.5D6C2CF4@earthling.net> <3432e5bf.68854036@forums.borland.com> Organization: Burgoyne Computers Inc. Newsgroups: comp.lang.java.programmer,comp.lang.java.api,borland.public.jbuilder.ide,borland.public.jbuilder.java.api,borland.public.jbuilder.java.language