Raw Thoughts ,Technology, Experiences


Compiling your Java App to Native Code.
February 5, 2006, 5:54 am
Filed under: Uncategorized

 Well, its quite unlike that you want to convert your Java App to Native Code, because of its Platform Independence. But  when an application is targetted to one particular platform probably we can convert to the native Code, that improves the speed of your app.

   Now the next Question would be .. How to Convert it? 

 Here is a code which converts to the Native Code…

—————————————————————————

//The #include directive treats
//text in the file specified by
//filename as if it appeared in the
//current file.
#include
#include

#include

//The #define directive defines a macro.
#define MAIN_CLASS “MyFrame.jar”
int main()
{

 //malloc() allocates a block of size
 //bytes from the memory heap.
 char* cmdline = (char*)malloc(1024 );

 //sends formatted output to a string
 sprintf( cmdline, “javaw.exe -jar %s”, MAIN_CLASS );

 //system() invokes the
 //DOS command interpreter
 system( cmdline );

 //deallocate the memory
 //block.
 free (cmdline);

 return 0;
}
————————————————————————


2 Comments so far
Leave a comment

is this wat they have done to netbeans also?? it gives an exe version of the ide for windows..

Comment by Aswin Anand

@Ashwin Anand :- Hey i havent worked much on Netbeans. well i dont think this is the only way to convert your app to exe for windows… its one of the simple ways..

You can actually go for installshield.. or there are umpteen number of softwares to do so.. But the power of our legacy “C” is significant in my above post..

Comment by ranganaths




Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>