首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >加载共享库时出错: jvm.dll

加载共享库时出错: jvm.dll
EN

Stack Overflow用户
提问于 2019-06-01 10:49:31
回答 1查看 360关注 0票数 0

我尝试了下面的代码

代码语言:javascript
复制
#include<jni.h>                                                          
#include<stdio.h>                                                        

int main(int argc, char** argv) {                                        

    JavaVM* vm;                                                      
    JNIEnv* env;                                                     
    JavaVMInitArgs vm_args;                                          
    vm_args.version = JNI_VERSION_1_2;                               
    vm_args.nOptions = 0;                                            
    vm_args.ignoreUnrecognized = 1;                                  

    // Construct a VM                                                
    jint results = JNI_CreateJavaVM(&vm, (void**)& env, &vm_args);   

    // Construct a String                                            
    jstring jstr = env->NewStringUTF("Hello World");                 

    // First get the class that contains the method you need to call 
    jclass clazz = env->FindClass("java/lang/String");               

    // Get the method that you want to call                          
    jmethodID to_lower = env->GetMethodID(clazz, "toLowerCase",      
            "()Ljava/lang/String;");                                 
    // Call the method on the object                                 
    jobject result = env->CallObjectMethod(jstr, to_lower);          

    // Get a C-style string                                          
    const char* str = env->GetStringUTFChars((jstring)result, NULL); 

    printf("%s\n", str);                                             

    // Clean up                                                      
    env->ReleaseStringUTFChars(jstr, str);                           

    // Shutdown the VM.                                              
    vm->DestroyJavaVM();
}                                                                 

我使用下面的命令来编译代码

代码语言:javascript
复制
g++ LoadJVM.c -I/c/apps64/Java/jdk-11.0.1/include -I/c/apps64/Java/jdk-11.0.1/include/win32 -L/c/apps64/Java/jdk-11.0.1/lib/ -ljvm

代码语言:javascript
复制
./a.exe

错误

代码语言:javascript
复制
error while loading shared libraries: jvm.dll: cannot open shared object file: No such file or directory
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56403503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档