从c ++代码运行可执行jar [英] run a executable jar from c++ code

查看:214
本文介绍了从c ++代码运行可执行jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一些C ++代码中执行 jar 文件。

I need to execute a jar file from inside of some C++ code.

我试过以下命令

int ret = execlp("java", "java", "-jar", "myprog.jar", (char *)0);

它工作正常。但我的问题是我的c ++主线程在执行我的jar文件后被停止。在执行jar文件之后不想停止我的c ++主线程。我可以这样做吗。

it's working fine.but my problem is my c++ main thread was stopped after executing my jar file.i don't want to stop my c++ main thread after excecuting jar file.how can i do this.

问候

推荐答案

解决这个问题的正常方法是从新生成的进程中fork()然后执行exec()。

The normal way to solve this problem is to fork() and then exec() from the newly spawned process.

这篇关于从c ++代码运行可执行jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆