Click here to Skip to main content
15,867,292 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor9-Jun-22 0:04
Valentinor9-Jun-22 0:04 
AnswerRe: Loading DLL from file not PATH Pin
Richard MacCutchan9-Jun-22 3:27
mveRichard MacCutchan9-Jun-22 3:27 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor9-Jun-22 6:21
Valentinor9-Jun-22 6:21 
GeneralRe: Loading DLL from file not PATH Pin
Victor Nijegorodov9-Jun-22 6:38
Victor Nijegorodov9-Jun-22 6:38 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan9-Jun-22 6:43
mveRichard MacCutchan9-Jun-22 6:43 
AnswerRe: Loading DLL from file not PATH Pin
Randor 10-Jun-22 6:54
professional Randor 10-Jun-22 6:54 
QuestionRe: Loading DLL from file not PATH Pin
Valentinor14-Jun-22 3:26
Valentinor14-Jun-22 3:26 
AnswerRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 5:10
mveRichard MacCutchan14-Jun-22 5:10 
This is the code I use to load a class from C++:
Java
 //
 // A function to start the Java VM and initialise the JNI interface
 //
JNIEnv* createJVM(
    JavaVM* jvm,
    std::string strcwd
)
{
    // tell the JVM where to find the class
    JavaVMOption    options{};
    std::stringstream ssoptions;
    ssoptions << "-Djava.class.path=";
    // the class files are in the current directory.
    // change this if yours are somewhere else
    ssoptions << strcwd;
    std::string stropts = ssoptions.str();
    options.optionString = const_cast<char*>(stropts.c_str());

    JavaVMInitArgs  vm_args; // JDK/JRE 6 VM initialization arguments
    vm_args.version = JNI_VERSION_1_8;
    vm_args.nOptions = 1;
    vm_args.ignoreUnrecognized = false;
    vm_args.options = &options;

    JNIEnv* env;            // pointer to native method interface
    // this should load the jvm.dll based on the PATH variable
    jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
    if (res != 0)
    {
        std::cout << "C++: JNI_CreateJavaVM returned: " << res << std::endl;
    }

    return env;
}

The caller then uses the env pointer to access the remaining JNI functions.
GeneralRe: Loading DLL from file not PATH Pin
Valentinor14-Jun-22 5:41
Valentinor14-Jun-22 5:41 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 5:49
mveRichard MacCutchan14-Jun-22 5:49 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor14-Jun-22 8:33
Valentinor14-Jun-22 8:33 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 9:27
mveRichard MacCutchan14-Jun-22 9:27 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 9:14
Valentinor15-Jun-22 9:14 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 22:30
mveRichard MacCutchan14-Jun-22 22:30 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 8:52
Valentinor15-Jun-22 8:52 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan15-Jun-22 21:53
mveRichard MacCutchan15-Jun-22 21:53 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 22:23
Valentinor15-Jun-22 22:23 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan15-Jun-22 22:46
mveRichard MacCutchan15-Jun-22 22:46 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 23:12
Valentinor15-Jun-22 23:12 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 0:01
mveRichard MacCutchan16-Jun-22 0:01 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor16-Jun-22 0:37
Valentinor16-Jun-22 0:37 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 2:08
mveRichard MacCutchan16-Jun-22 2:08 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 5:22
mveRichard MacCutchan16-Jun-22 5:22 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor16-Jun-22 6:06
Valentinor16-Jun-22 6:06 
QuestionMeasure ITEM ITEMDATA string coming in as Wide Character string Pin
ForNow6-Jun-22 17:28
ForNow6-Jun-22 17:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.