Click here to Skip to main content
15,894,720 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: c++ Pin
tuanguyen200021-Jun-22 22:50
tuanguyen200021-Jun-22 22:50 
GeneralRe: c++ Pin
tuanguyen200021-Jun-22 22:51
tuanguyen200021-Jun-22 22:51 
GeneralRe: c++ Pin
CPallini21-Jun-22 23:08
mveCPallini21-Jun-22 23:08 
GeneralRe: c++ Pin
Richard MacCutchan22-Jun-22 1:20
mveRichard MacCutchan22-Jun-22 1:20 
QuestionMessage Closed Pin
16-Jun-22 5:53
Member 1496877116-Jun-22 5:53 
AnswerRe: parsing interactive text Pin
Mircea Neacsu16-Jun-22 8:09
Mircea Neacsu16-Jun-22 8:09 
AnswerRe: parsing interactive text Pin
trønderen16-Jun-22 10:52
trønderen16-Jun-22 10:52 
JokeRe: parsing interactive text Pin
Peter_in_278016-Jun-22 11:56
professionalPeter_in_278016-Jun-22 11:56 
AnswerRe: parsing interactive text Pin
Richard MacCutchan18-Jun-22 2:50
mveRichard MacCutchan18-Jun-22 2:50 
QuestionCan importing C++ DLL files in a C# project has a positive effect on the overall performance of the application? Pin
Code4Ever10-Jun-22 8:39
Code4Ever10-Jun-22 8:39 
AnswerRe: Can importing C++ DLL files in a C# project has a positive effect on the overall performance of the application? Pin
Dave Kreskowiak10-Jun-22 9:56
mveDave Kreskowiak10-Jun-22 9:56 
QuestionLoading DLL from file not PATH Pin
Valentinor8-Jun-22 22:59
Valentinor8-Jun-22 22:59 
AnswerRe: Loading DLL from file not PATH Pin
Victor Nijegorodov8-Jun-22 23:16
Victor Nijegorodov8-Jun-22 23:16 
GeneralRe: Loading DLL from file not PATH Pin
Valentinor8-Jun-22 23:48
Valentinor8-Jun-22 23:48 
GeneralRe: Loading DLL from file not PATH Pin
Victor Nijegorodov8-Jun-22 23:52
Victor Nijegorodov8-Jun-22 23:52 
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 

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.