Re: java to native code and Sun JVM alternatives
wagde <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Thanx Andrew for the quick reply. I'm trying to link my c code and I get: undefined reference to `JNI_CreateJavaVM' Although I have -lgcj in my ld command and it's the only undefined symbol in my code. Why is that? I still don't understand how JNI_CreateJavaVM will create a gij VM and not sun JAVA VM. can you explain this to me. Thanx Wagde Andrew Haley wrote: > > On 03/11/2010 11:45 AM, wagde wrote: >> >> I'm working on a project which have java code (and c++), and until ow I >> used >> javac to compile the code and java to run the classes and JNI to call >> java >> from c++ code. >> >> I don't want to use javac, javah, and java, ...(sun stuff) because of >> royalties issues... > > OpenJDK is free software, but let's press on... > >> I'm looking for alternatives. >> >> What I see right now are two alternatives: >> 1. compile my java code to native code using gcj, and link it with the >> c++ >> code. >> 2. keep the classes and use the gij instead of java. >> >> I start working on the two approaches in parallel and I'm having too many >> problems in both them. So I need some REAL help here. >> >> Problem with 1. >> 1. I succeeded to compile my java code (after chaning the syntax) using >> gcj >> to linux "c" object files. But in the linkage to the binary, I got too >> many >> "undefined reference to", ... because I use external "jars" (like axis) >> which are not compiled to native. I try to compile the axis jar to c and >> get >> too many compilation errors. > > Compiling Java code with -findirect-dispatch is probably your best > plan to solve this. When an undefined class is discoveed, gcj's > runtime will try to load its class files. > >> Problem with 2. >> I compiled all my classes with gcj. and the C code uses JNI to call it. >> But >> the JNI creates a JVM (JNI_CreateJavaVM)!!! which I don't want to use. > > Why not? This is fully supported by gcj, and doesn't hurt anything. > >> I want to use gij instead. So I wanted to know if there is anyway to >> let my JNI code to ceate a gij VM and and java VM. is there anything >> like this ?! If not, how can I use the classes I compiled with gcj >> from the c code without using the JAVA VM? CNI? does that mean that >> I should convert my jni code to cni? > > No, there's no need to do that. JNI code should work with gcj just > fine. > > Andrew. > > -- View this message in context: http://old.nabble.com/java-to-native-code-and-Sun-JVM-alternatives-tp27862420p27895737.html Sent from the gcc - java mailing list archive at Nabble.com.