Click here to Skip to main content
15,920,031 members
Home / Discussions / Java
   

Java

 
AnswerRe: full answer with code pls Pin
jschell6-Feb-23 6:21
jschell6-Feb-23 6:21 
AnswerRe: full answer with code pls Pin
Dave Kreskowiak6-Feb-23 6:32
mveDave Kreskowiak6-Feb-23 6:32 
GeneralRe: full answer with code pls Pin
Andre Oosthuizen8-Feb-23 4:30
mveAndre Oosthuizen8-Feb-23 4:30 
AnswerRe: full answer with code pls Pin
Richard MacCutchan6-Feb-23 6:37
mveRichard MacCutchan6-Feb-23 6:37 
AnswerRe: full answer with code pls Pin
Gerry Schmitz6-Feb-23 6:39
mveGerry Schmitz6-Feb-23 6:39 
QuestionUsing JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 20:38
JohnCodding25-Jan-23 20:38 
AnswerRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan25-Jan-23 22:31
mveRichard MacCutchan25-Jan-23 22:31 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 22:47
JohnCodding25-Jan-23 22:47 
Can you include a project with this? I tried it inside a project with c++17 but I'm getting 29 errors.

It marks these lines as problems:

std::filesystem::path jvmpath(jrePath);       // name followed by '::' must be a class or namespace name   and expected a;
    jvmpath /= pszjvmname;                    // identifier jvmpath undifined
    if (!std::filesystem::exists(jvmpath)) {  // name followed by '::' must be a class or namespace name 


std::filesystem::path cwd = std::filesystem::current_path();   // name followed by '::' must be a class or namespace name   and expected a;


jniEnv = AttachJVM(jreDir, &jvm, cwd.string()); // identifier cwd undifined



Right now I'm using this to create a VM:

FString UCreateVM::createVM(FString location) {
	std::string javaLocation = TCHAR_TO_ANSI(*location);
	javaLocation.insert(0, "-Djava.class.path=");
	javaLocation.append("Data/Java");
	JavaVMInitArgs vm_args;
	JavaVMOption* options = new JavaVMOption[1];
	options[0].optionString = &javaLocation[0];
	vm_args.version = JNI_VERSION_10;
	vm_args.nOptions = 1;
	vm_args.options = options;
	vm_args.ignoreUnrecognized = false;
	JNIEnv* env = nullptr;
	jint rc = JNI_OK;
	if (jvm == nullptr) {
		rc = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
	}
	else {
		rc = jvm->AttachCurrentThread((void**)&env, NULL);
	}
	delete[] options;
	if (rc != JNI_OK) {
		if (rc == JNI_EVERSION)
			return "JNI_EVERSION";
		else if (rc == JNI_ENOMEM)
			return "JNI_ENOMEM";
		else if (rc == JNI_EINVAL)
			return "JNI_EINVAL";
		else if (rc == JNI_EEXIST)
			return "JNI_EEXIST";
		else
			return "JNI_FATALERROR";
	}
	return "JNI_CREATED";
}


Also, I should mention that I'm using Eclipse Adoptium Java JRE, and it will be distributed with the app (with all the legal stuff), and in the above function I can add another parameter and tell it where the path for the dll is located inside the app/Eclipse Adoptium Java JRE folder.

modified 26-Jan-23 5:03am.

GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:02
mveRichard MacCutchan26-Jan-23 0:02 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:16
JohnCodding26-Jan-23 0:16 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding25-Jan-23 23:27
JohnCodding25-Jan-23 23:27 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:05
mveRichard MacCutchan26-Jan-23 0:05 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:20
JohnCodding26-Jan-23 0:20 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 0:28
mveRichard MacCutchan26-Jan-23 0:28 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:45
JohnCodding26-Jan-23 0:45 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
JohnCodding26-Jan-23 0:52
JohnCodding26-Jan-23 0:52 
GeneralRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
Richard MacCutchan26-Jan-23 1:44
mveRichard MacCutchan26-Jan-23 1:44 
AnswerRe: Using JNI without having to add jvm.dll path inside Environment Variables (User or System) Pin
jschell26-Jan-23 11:33
jschell26-Jan-23 11:33 
QuestionMemory usage for requested rows from database Pin
Valentinor13-Jan-23 0:18
Valentinor13-Jan-23 0:18 
AnswerRe: Memory usage for requested rows from database Pin
jschell15-Jan-23 8:27
jschell15-Jan-23 8:27 
GeneralRe: Memory usage for requested rows from database Pin
Valentinor16-Jan-23 20:44
Valentinor16-Jan-23 20:44 
GeneralRe: Memory usage for requested rows from database Pin
jschell17-Jan-23 3:24
jschell17-Jan-23 3:24 
AnswerRe: Memory usage for requested rows from database Pin
RedDk17-Jan-23 7:15
RedDk17-Jan-23 7:15 
QuestionHow to found a file by utilizing a variable for 'Startswith' in JAVA? Pin
MOHAMMAD ZAINUL ABIDEEN3-Jan-23 0:32
MOHAMMAD ZAINUL ABIDEEN3-Jan-23 0:32 
AnswerRe: How to found a file by utilizing a variable for 'Startswith' in JAVA? Pin
Richard MacCutchan3-Jan-23 1:22
mveRichard MacCutchan3-Jan-23 1:22 

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.