В общем есть параметр
java -Djava.library.path=/home/linuz/qt-projects/build-launcher-Desktop-Debug/versions/1.8.7/natives -cp /home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/io/netty/netty-all/4.0.23.Final/netty-all-4.0.23.Final.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/google/guava/guava/17.0/guava-17.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-codec/commons-codec/1.9/commons-codec-1.9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/mojang/authlib/1.5.21/authlib-1.5.21.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/mojang/realms/1.7.21/realms-1.7.21.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/tv/twitch/twitch/6.5/twitch-6.5.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/versions/1.8.7/1.8.7.jar net.minecraft.client.main.Main --accessToken null --version 1.8.7
Шаблон этого параметра
java -Djava.library.path={natives_path} -cp {classpath} net.minecraft.client.main.Main --accessToken null --version {version}
В принципе ничего сложно, просто classpath толстоват!
Произвел дамп аргументов JavaVM
Увидел что обычные аргументы идут в sun.java.command, а {classpath} указывается в java.class.path, {native_path} в java.library.path.
Ну ладно, раз так все просто, делаю следующее.
bool Jvm::launchJVM()
{
jargs.clear();
jargs.append("-Djava.library.path=/home/linuz/qt-projects/build-launcher-Desktop-Debug/versions/1.8.7/natives");
jargs.append("-Djava.class.path=/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/io/netty/netty-all/4.0.23.Final/netty-all-4.0.23.Final.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/google/guava/guava/17.0/guava-17.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-codec/commons-codec/1.9/commons-codec-1.9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/mojang/authlib/1.5.21/authlib-1.5.21.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/com/mojang/realms/1.7.21/realms-1.7.21.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/logging/log4j/log4j-api/2.0-beta9/log4j-api-2.0-beta9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/apache/logging/log4j/log4j-core/2.0-beta9/log4j-core-2.0-beta9.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/libraries/tv/twitch/twitch/6.5/twitch-6.5.jar:/home/linuz/qt-projects/build-launcher-Desktop-Debug/versions/1.8.7/1.8.7.jar");
jargs.append("-Dsun.java.command=net.minecraft.client.main.Main --accessToken null --version 1.8.7");
jint alength = (jint)jargs.length();
__debug_p("Args lenght" << alength);
if(alength < 1)
{
__DEBUG_P("No java options");
return false;
}
__DEBUG_P("Launching Java VM...");
JavaVMOption options[alength];
//jargs.setSharable(true);
QByteArray *arrs = new QByteArray[alength];
foreach(QString param, jargs)
{
static int i = 0;
//options[i].optionString = param.toLatin1().data();
//QByteArray arr = param.toLocal8Bit();
arrs[i] = param.toLocal8Bit();
char * pbuff = arrs[i].data();
options[i].optionString = pbuff;
//options[i].optionString = const_cast<char*>(param.toStdString().c_str());
i++;
}
for(int i = 0; i < alength; i++)
{
qDebug() << "%$$%$%$%POINTER IN STRUCT" << options[i].optionString << endl;
}
JavaVMInitArgs vm_args;
/* jint ret = JNI_GetDefaultJavaVMInitArgs(&vm_args);
if(ret == JNI_ERR)
__debug_p("Error while loading default jvm init args"); //*/
vm_args.version = JNI_VERSION_1_6;
vm_args.options = options;
vm_args.nOptions = alength;
vm_args.ignoreUnrecognized = JNI_FALSE;
jint code = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
if(code == JNI_ERR)
{
__DEBUG_P("JVM is not runned, error code" << code);
return false;
}
//__debug_p("Attaching" << jvm->AttachCurrentThreadAsDaemon((void**)&env, &vm_args));
__DEBUG_P("JVM runned successful");
emit JavaVMRunned(env);
return true;
}
И не запускается! Что-то не так с этими аргументами -Dsun.java.command=net.minecraft.client.main.Main --accessToken null --version 1.8.7
Видимо их указывать нужно по другому, кто вкурсе? И можно ли логи jvm перенаправить в обычный вывод Qt?