【Java App Convert to EXE File】

* ------------------------------------------------------------------------------------
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....

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值