Click here to Skip to main content
16,007,443 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCan we get Username of the person who is logged into the system? Pin
megha_gharote25-Sep-07 0:22
megha_gharote25-Sep-07 0:22 
AnswerRe: Can we get Username of the person who is logged into the system? Pin
Nishad S25-Sep-07 0:53
Nishad S25-Sep-07 0:53 
GeneralRe: Can we get Username of the person who is logged into the system? Pin
megha_gharote25-Sep-07 1:12
megha_gharote25-Sep-07 1:12 
GeneralRe: Can we get Username of the person who is logged into the system? Pin
Nishad S25-Sep-07 1:30
Nishad S25-Sep-07 1:30 
QuestionMessages between threads... Pin
eli1502197925-Sep-07 0:00
eli1502197925-Sep-07 0:00 
AnswerRe: Messages between threads... Pin
DevMentor.org25-Sep-07 0:52
DevMentor.org25-Sep-07 0:52 
AnswerRe: Messages between threads... Pin
nbugalia25-Sep-07 1:16
nbugalia25-Sep-07 1:16 
QuestionINVOKING JAVA METHOD FROM C++ Pin
amitamit19824-Sep-07 23:10
amitamit19824-Sep-07 23:10 
i am using jdk1.4 and vc++ 6.0 console application !

//Its tt.java simple Helloworld program .which i am willing to call from c++
// i created .class and .h file of it !

public class tt {
public static void main(String[] args) {
System.out.println("Hello World ");
}
}

//*****************************************************************************************


//i wrote it in vc++ 6.0
//for this i added path of tt.h(created using javah) in preprocessor path(underprojects=>setting=>c/c++ tab)
//then added path of jvm.lib (under projects=>setting=>link tab)


#include "jni.h"
#define PATH_SEPARATOR ';' /* define it to be ':' on Solaris */
#define USER_CLASSPATH "C:\j2sdk1.4.2_05\bin" /* where tt.class is */

int main()
{
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jclass stringClass;
jobjectArray args;;
JavaVMInitArgs vm_args;;
JavaVMOption options[1];
options[0].optionString ="-Djava.class.path="USER_CLASSPATH;
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);


if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
// exit(1);
}
cls = (env)->FindClass("tt");
if (cls == 0) {
// goto destroy;
}

mid = (env)->GetStaticMethodID(cls, "main","([Ljava/lang/StringV");
if (mid == 0) {
// goto destroy;
}
jstr = (env)->NewStringUTF(" from C!");
if (jstr == 0) {
// goto destroy;
}
stringClass = (env)->FindClass("java/lang/String");
args = (env)->NewObjectArray(1, stringClass, jstr);
if (args == 0) {
// goto destroy;
}
(env)->CallStaticVoidMethod(cls, mid, args);

//destroy:
if ((env)->ExceptionOccurred()) {
(env)->ExceptionDescribe();
}
(jvm)->DestroyJavaVM();
return 0;
}


/// After doing that much ! program gets compiled easily but at run it says JVM cant created and returns error value -1 means unknown error (as per jni.h)


// please help me sir....what changes i should do so that it gets run n calls java method ?
AnswerRe: INVOKING JAVA METHOD FROM C++ Pin
KarstenK25-Sep-07 1:31
mveKarstenK25-Sep-07 1:31 
GeneralJust a tip Pin
Nelek25-Sep-07 2:06
protectorNelek25-Sep-07 2:06 
Questionya machine version is 1.4 Pin
amitamit19825-Sep-07 3:22
amitamit19825-Sep-07 3:22 
QuestionActiveX Control Test Container Pin
p_24-Sep-07 23:10
p_24-Sep-07 23:10 
AnswerRe: ActiveX Control Test Container Pin
nbugalia24-Sep-07 23:30
nbugalia24-Sep-07 23:30 
GeneralRe: ActiveX Control Test Container Pin
p_24-Sep-07 23:40
p_24-Sep-07 23:40 
GeneralRe: ActiveX Control Test Container Pin
nbugalia25-Sep-07 0:19
nbugalia25-Sep-07 0:19 
GeneralRe: ActiveX Control Test Container Pin
p_25-Sep-07 0:23
p_25-Sep-07 0:23 
GeneralRe: ActiveX Control Test Container Pin
nbugalia25-Sep-07 1:06
nbugalia25-Sep-07 1:06 
GeneralRe: ActiveX Control Test Container Pin
p_25-Sep-07 1:19
p_25-Sep-07 1:19 
GeneralRe: ActiveX Control Test Container Pin
nbugalia25-Sep-07 1:52
nbugalia25-Sep-07 1:52 
QuestionOpening a web site from VC++ application Pin
megha_gharote24-Sep-07 22:38
megha_gharote24-Sep-07 22:38 
AnswerRe: Opening a web site from VC++ application Pin
Nishad S24-Sep-07 22:59
Nishad S24-Sep-07 22:59 
GeneralRe: Opening a web site from VC++ application Pin
toxcct24-Sep-07 23:36
toxcct24-Sep-07 23:36 
GeneralRe: Opening a web site from VC++ application Pin
Nishad S25-Sep-07 0:14
Nishad S25-Sep-07 0:14 
AnswerRe: Opening a web site from VC++ application Pin
Hamid_RT24-Sep-07 23:01
Hamid_RT24-Sep-07 23:01 
AnswerRe: Opening a web site from VC++ application Pin
p_24-Sep-07 23:14
p_24-Sep-07 23:14 

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.