Built From Developers For Developers
» Kuikie.com » Snippets » CPP » Other » CPP. Execute a Java class on Windows
  Categories
  CPP
    Other
    Qt
 

CPP. Execute a Java class on Windows

This small CPP snippet sends a command to the Java virtual machine to run a specified Java class. This can be useful, if we want the Java application to have a native executable.

#include <windows.h>
#include <stdio.h>
#define MAIN_CLASS  "MyApplication"
int main( int argc, char** argv )
{
  char* cmdline = malloc( 1024 ); /* big buffer */
  sprintf( cmdline, "java.exe %s", MAIN_CLASS );
  system( cmdline );
  return 0;
}
 
©2012 Sinevia Ltd Terms of Use         Privacy Policy Valid XHTML 1.0 Transitional