feedme java project

is free software, licensed under the terms of the GNU General Public License, that feeds/imports media from anywhere to xbox360 media center extenders, ipods, web servers, file servers, etc. using Java.

Please read the license here.

Friday, August 24, 2007

JNI 6.0


// Unmanaged.h:

class UnmanagedClass;

typedef void (UnmanagedClass::*PointerToMember)(void);

class UnmanagedClass
{
public:
void Member();
PointerToMember __thiscall GetPointerToMember();
};

// Unmanaged.cpp:
// compile with "cl /c /MD /EHa Unmanaged.cpp"

#include

#include "Unmanaged.h"

PointerToMember __thiscall UnmanagedClass::GetPointerToMember()
{
std::cout << __FUNCSIG__ << std::endl;
return &UnmanagedClass::Member;
}

void UnmanagedClass::Member()
{
std::cout << __FUNCSIG__ << std::endl;
}

// Managed.cpp:
// build with "cl /clr Managed.cpp /link Unmanaged.obj"

#include "Unmanaged.h"

int main()
{
UnmanagedClass myObject;
PointerToMember myPointerToMember = myObject.GetPointerToMember();
(myObject.*myPointerToMember)();
}


Most common reasons for crashes.
1. User JNI code (most likely)
2. Third party JNI code.
3. VM (least likely)








//Test1.java
class Test1
{
static
{
System.loadLibrary("TestDll");
}
public static void main(String ar[])
{
System.out.println("Hello world from Java");
Test1 t=new Test1();
t.inDll();
}
public native void inDll();
}
Go to Project/Settings, on C/C++ tab, go to Project option, insert following lines at the end:
/I ":\\include "
/I ":\\include\win32"

Now compile and generate your DLL, put newly created DLL in system32 directory and then run your class file. It should work properly. If you receive an error like UnsatisfiedLinkError, then recheck your procedure.

No comments: