简体   繁体   English

"如何从 32 位 C++ 应用程序启动 64 位 Java 应用程序?"

[英]How to start 64-bit Java application from 32-bit C++ application?

I'm using a simple C++ program to run an executable .jar file in Windows 7 64 bit.我正在使用一个简单的 C++ 程序在 Windows 7 64 位中运行一个可执行的 .jar 文件。 I expected this to execute 64 bit java, but it doesn't, it executes the 32 bit version.我希望它执行 64 位 java,但它没有,它执行 32 位版本。

I'm using the following code:我正在使用以下代码:

const char* javaw_path     = "javaw.exe";
const std::string memory   = "-Xmx" + user_configured_memory();
const char* jar            = "-jar";
const char* jar_file       = "\"HelloWorld.jar\"";
const std::string cli_args =  get_cli_args(argc, argv);

const char* args[] = {javaw_path, memory.c_str(),
       jar, jar_file, cli_args.c_str(), static_cast<char*>(NULL)};    

const int ret = execvp(javaw_path, args);

We can have combinations of OS, JDK and Eclipse bit--ness, for instance a 64-bit JDK with a 32-bit Eclipse on a 64-bit OS, or 32-bit OS, 32-bit JDK, 32-bit Eclipse, 64-bit OS, 32-bit JDK, 32-bit Eclipse, or 64-bit OS, 64-bit JDK, 64-bit Eclipse.我们可以有操作系统、JDK 和 Eclipse 位的组合,例如 64 位 JDK 和 32 位 Eclipse 在 64 位操作系统上,或者 32 位操作系统、32 位 JDK、32 位 Eclipse 、64 位操作系统、32 位 JDK、32 位 Eclipse 或 64 位操作系统、64 位 JDK、64 位 Eclipse。 As someone mentioned above, if your programming in C++ on 32-bit, cannot be compiled, it has to be done on 64-bit and of course another 64-bit app to run the exe.如上所述,如果您在 32 位上使用 C++ 进行的编程无法编译,则必须在 64 位上完成,当然还有另一个 64 位应用程序才能运行该 exe。

"

If your C++ program is 32-bit, you can't do it. 如果您的C ++程序是32位的,则不能这样做。 You must compile the C++ app as 64-bit and then you can call another 64-bit app from the executable. 您必须将C ++应用程序编译为64位,然后才能从可执行文件中调用另一个64位应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM