Click here to Skip to main content
15,917,329 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: How to set an Integer value to System::String ^ Pin
Luc Pattyn22-Nov-08 9:35
sitebuilderLuc Pattyn22-Nov-08 9:35 
JokeRe: How to set an Integer value to System::String ^ Pin
killabyte28-Nov-08 22:32
killabyte28-Nov-08 22:32 
AnswerRe: How to set an Integer value to System::String ^ Pin
sajjy29-Nov-08 11:15
sajjy29-Nov-08 11:15 
QuestionDisplaying Windows Explorer Pin
progDes21-Nov-08 18:32
progDes21-Nov-08 18:32 
AnswerRe: Displaying Windows Explorer Pin
Christian Graus21-Nov-08 21:25
protectorChristian Graus21-Nov-08 21:25 
GeneralRe: Displaying Windows Explorer Pin
progDes21-Nov-08 23:40
progDes21-Nov-08 23:40 
QuestionCreating a dll, mixing c/c++ and java Pin
Hector_M20-Nov-08 23:04
Hector_M20-Nov-08 23:04 
AnswerRe: Creating a dll, mixing c/c++ and java Pin
Hector_M21-Nov-08 1:47
Hector_M21-Nov-08 1:47 
i have solved the problem: these are the steps i have followed

1.- Create a java class with native methods. Create code to load the dll library.
Example:

import java.io.File;
/**
* @author hectorhg
*
*/
public class CLangWrapper {
/**
* Path of the .dll file
*/
public static final String dllName = "C:\\clangwrapper.dll";

// Code to Load the dll
static{
try{
File l_file = new File(".");
System.load(dllName);
}
catch (UnsatisfiedLinkError e) {
e.printStackTrace();
}
catch (Exception ex){
ex.printStackTrace();
}
}

/*********************************************
* N A T I V E M E T H O D S *
*********************************************/

/**
* Starts wrapper
* @return
*/
public static native int wrapperStart();
}

2.- javac myclass.java

3.- javah -jni package.myclass # in the ../ directory of package.

4.- A .h file is generated. implement it in a .c file.

5.- I have used vs2008, to create a dll project. In this project i included those files (don't forget about jni.h and jni_md.h) and my .cpp files.

6.- in the .c file implementing the native methods.

struct CPLUPLUSCLASS cppClass; // Global variable

#if defined(__GNUC__) && defined(_WIN32)
extern "C" JNIEXPORT jint JNICALL Java_sidsaTvAppControl_CLangWrapper_wrapperStart
(JNIEnv *, jobject){
#else
JNIEXPORT jint JNICALL Java_sidsaTvAppControl_CLangWrapper_wrapperStart
(JNIEnv *, jobject){
#endif
jint l_retVal = 0;

l_retVal = cppClass.myFunc();


return l_retVal;
}


7.- Note that the file that implements the .h file generated by jni must be included in the dll.

8.- compile and place the .dll into the rigth directory according to your java class implementation.

9.- run your java application.

10.- Check everything is working and smile Wink | ;-)

I hope that this can help someone Big Grin | :-D

Regards,

Hector.
QuestionUsing unmanaged dll with C++/CLI Pin
pratap198020-Nov-08 12:39
pratap198020-Nov-08 12:39 
AnswerRe: Using unmanaged dll with C++/CLI Pin
Dave Doknjas20-Nov-08 13:11
Dave Doknjas20-Nov-08 13:11 
Question[Message Deleted] Pin
vikramaditya23418-Nov-08 20:41
vikramaditya23418-Nov-08 20:41 
AnswerRe: porting in RHEL (UNIX) Pin
led mike20-Nov-08 4:44
led mike20-Nov-08 4:44 
AnswerRe: porting in RHEL (UNIX) Pin
Paul Conrad20-Nov-08 5:56
professionalPaul Conrad20-Nov-08 5:56 
QuestionSave Socket^ variable in the global scope Pin
cra03418-Nov-08 2:14
cra03418-Nov-08 2:14 
AnswerRe: Save Socket^ variable in the global scope Pin
led mike18-Nov-08 5:00
led mike18-Nov-08 5:00 
QuestionChecking Latest Virus Scan? Pin
DarthKarnage17-Nov-08 5:51
DarthKarnage17-Nov-08 5:51 
AnswerCross Post Pin
led mike18-Nov-08 5:07
led mike18-Nov-08 5:07 
Question[Message Deleted] Pin
De@r17-Nov-08 3:49
De@r17-Nov-08 3:49 
AnswerRe: bubble sort to quick sort Pin
73Zeppelin17-Nov-08 6:15
73Zeppelin17-Nov-08 6:15 
QuestionSTL/CLR Pin
staticv17-Nov-08 1:31
staticv17-Nov-08 1:31 
QuestionSyntax Error Help: Switch Statement Code Pin
Olaman15-Nov-08 18:09
Olaman15-Nov-08 18:09 
AnswerRe: Syntax Error Help: Switch Statement Code Pin
Mark Salsbery16-Nov-08 6:49
Mark Salsbery16-Nov-08 6:49 
QuestionPostMessage fails in Windows Service [modified] Pin
Indivara13-Nov-08 14:29
professionalIndivara13-Nov-08 14:29 
GeneralRe: PostMessage fails in Windows Service Pin
Mark Salsbery15-Nov-08 12:32
Mark Salsbery15-Nov-08 12:32 
GeneralRe: PostMessage fails in Windows Service Pin
Indivara16-Nov-08 14:28
professionalIndivara16-Nov-08 14: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.