Click here to Skip to main content
15,506,023 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor9-Jun-22 1:04
Valentinor9-Jun-22 1:04 
AnswerRe: Loading DLL from file not PATH Pin
Richard MacCutchan9-Jun-22 4:27
mveRichard MacCutchan9-Jun-22 4:27 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor9-Jun-22 7:21
Valentinor9-Jun-22 7:21 
GeneralRe: Loading DLL from file not PATH Pin
Victor Nijegorodov9-Jun-22 7:38
Victor Nijegorodov9-Jun-22 7:38 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan9-Jun-22 7:43
mveRichard MacCutchan9-Jun-22 7:43 
AnswerRe: Loading DLL from file not PATH Pin
Randor 10-Jun-22 7:54
professional Randor 10-Jun-22 7:54 
QuestionRe: Loading DLL from file not PATH Pin
Valentinor14-Jun-22 4:26
Valentinor14-Jun-22 4:26 
AnswerRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 6:10
mveRichard MacCutchan14-Jun-22 6: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 6:41
Valentinor14-Jun-22 6:41 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 6:49
mveRichard MacCutchan14-Jun-22 6:49 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor14-Jun-22 9:33
Valentinor14-Jun-22 9:33 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 10:27
mveRichard MacCutchan14-Jun-22 10:27 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 10:14
Valentinor15-Jun-22 10:14 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan14-Jun-22 23:30
mveRichard MacCutchan14-Jun-22 23:30 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 9:52
Valentinor15-Jun-22 9:52 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan15-Jun-22 22:53
mveRichard MacCutchan15-Jun-22 22:53 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor15-Jun-22 23:23
Valentinor15-Jun-22 23:23 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan15-Jun-22 23:46
mveRichard MacCutchan15-Jun-22 23:46 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor16-Jun-22 0:12
Valentinor16-Jun-22 0:12 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 1:01
mveRichard MacCutchan16-Jun-22 1:01 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor16-Jun-22 1:37
Valentinor16-Jun-22 1:37 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 3:08
mveRichard MacCutchan16-Jun-22 3:08 
GeneralRe: Loading DLL from file not PATH Pin
Richard MacCutchan16-Jun-22 6:22
mveRichard MacCutchan16-Jun-22 6:22 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor16-Jun-22 7:06
Valentinor16-Jun-22 7:06 
QuestionMeasure ITEM ITEMDATA string coming in as Wide Character string Pin
ForNow6-Jun-22 18:28
ForNow6-Jun-22 18: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.