【Java App Convert to EXE File】
2009-12-19 10:44
295 查看
* ------------------------------------------------------------------------------------
Title: TestJava.cpp
author: gloomy fish on 2009-09-16
------------------------------------------------------------------------------------
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
/* for spawn
*/
#include <process.h>
/* for str* functions
*/
#include <string.h>
#include <TCHAR.H>
//-------------------------------------------------------------------------------
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// -- check wether application is running now....
HANDLE hMutex = CreateMutex (NULL,
// No security descriptor
FALSE,
// Mutex object not owned
TEXT("TotallyBogusMutexObjectPlateUtility"));
// Object name
if (NULL
== hMutex)
{
// Didn't expect this to happen!
printf("Mutex is null");
return
1;
}
else
{
// Not an error -- deal with success
if ( ERROR_ALREADY_EXISTS
== GetLastError() )
{
return
0;
}
}
// -- set up classpath & env path to launch
int ret;
TCHAR envPath[3072]
= "PATH=.;D://JDK6//bin;%path%";
int anErr
= _tputenv(envPath);
if (anErr
!= 0) {
ret = anErr;
return ret;
}
char jvmArg[2048];
// append all necessary jars to set up classpath
_tcscpy(jvmArg, _T("-cp .//test.jar"));
// _tcscat(jvmArg, _T(";D://JDK6//lib"));
// -- your application
_tcscat(jvmArg, _T(" -Xms256m -Xmx1024m com.swing.ui.Test") );
// -- can't launch like this......
#ifdef _DEBUG
ret = _spawnlp(_P_NOWAIT,
"..//..//JDK6//bin//java.exe",
"java", jvmArg, NULL);
#else
ret = _spawnlp(_P_NOWAIT,
"..//..//JDK6//bin//javaw.exe",
"java", jvmArg, NULL);
#endif
return ret;
}
// winXP, vc++6.0 compile successfully....
Title: TestJava.cpp
author: gloomy fish on 2009-09-16
------------------------------------------------------------------------------------
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
/* for spawn
*/
#include <process.h>
/* for str* functions
*/
#include <string.h>
#include <TCHAR.H>
//-------------------------------------------------------------------------------
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// -- check wether application is running now....
HANDLE hMutex = CreateMutex (NULL,
// No security descriptor
FALSE,
// Mutex object not owned
TEXT("TotallyBogusMutexObjectPlateUtility"));
// Object name
if (NULL
== hMutex)
{
// Didn't expect this to happen!
printf("Mutex is null");
return
1;
}
else
{
// Not an error -- deal with success
if ( ERROR_ALREADY_EXISTS
== GetLastError() )
{
return
0;
}
}
// -- set up classpath & env path to launch
int ret;
TCHAR envPath[3072]
= "PATH=.;D://JDK6//bin;%path%";
int anErr
= _tputenv(envPath);
if (anErr
!= 0) {
ret = anErr;
return ret;
}
char jvmArg[2048];
// append all necessary jars to set up classpath
_tcscpy(jvmArg, _T("-cp .//test.jar"));
// _tcscat(jvmArg, _T(";D://JDK6//lib"));
// -- your application
_tcscat(jvmArg, _T(" -Xms256m -Xmx1024m com.swing.ui.Test") );
// -- can't launch like this......
#ifdef _DEBUG
ret = _spawnlp(_P_NOWAIT,
"..//..//JDK6//bin//java.exe",
"java", jvmArg, NULL);
#else
ret = _spawnlp(_P_NOWAIT,
"..//..//JDK6//bin//javaw.exe",
"java", jvmArg, NULL);
#endif
return ret;
}
// winXP, vc++6.0 compile successfully....
相关文章推荐
- 【Java App Convert to EXE File】
- 【Java App Convert to EXE File】
- How to convert Java Key Store file to pem/key for nginx
- Java: convert a file to a byte array, then convert byte array to a file.
- Execution failed for task ':app:compileDebugJavaWithJavac'. Failed to create MD5 hash for file ...
- 解决异常:java.lang.ClassCastException:android.app.Aplication cannot be cast to 类名
- java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.
- java.lang.IllegalStateException: Web app root system property already set to different value: 'webap
- Android:Your APP_BUILD_SCRIPT points to an unknown file
- 【8】JAVA---地址App小软件(AddrDaoFile .class)(数据层)
- 【iOS问题】The file “XXX.app” couldn’t be opened because you don’t have permission to view it.
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this
- Convert uid to packageName or appName
- How To Convert Maven Based Java Project To Support Eclipse IDE
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant
- Using Java to process excel file
- ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn'
- 【LeetCode】405 Convert a Number to Hexadecimal (java实现)
- 表单提交时候"Failed to convert property value of type [java.lang.String] to
- Convert stardict dict to txt file