473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

JNI Phun.....


I'm trying to understand JNI well enough to be be able to supply
a state model class in C++ to some client applications and use the
same model in the JAVA app that controls the clients.
The state model class is written.
I thought a good place to start might be with the JAVA JNI Tutorial
HelloWorld instance, so I set up HelloWorld.java, compiled it, ran it
through javah, setup the HelloWorldImp.c ( native C language method )
and compiled it per the instructions ( or what the instructions implied ):

got HelloWorld.java
java HelloWorld.java
javah -jni HelloWorld
checked HelloWorld.h
got HelloWorldImp.c

Set LD_LIBRARY_PATH to the PWD since thats where everything resides

compiled HelloWorldImp.c as follow:

ZZZZ=HelloWorldImp.c
JJJJ=/usr/java/sdk ( 1.4.2_01 as it happens )
CPPOPT="-c -g -shared"
gcc $CPPOPT -I$JJJJ/include -I$JJJJ/include/linux $ZZZZ -o libhello.so
I am running on a RedHat 9 Linux box by the way.

Got the resulting libhello.so and then tried to run the app

java HelloWorld

What I got was:

Exception in thread "main" java.lang.UnsatisfiedLinkError: \
<obfuscated>/JNI_d/libhello.so: \
<obfuscated>/JNI_d/libhello.so: \
ELF file's phentsize not the expected size
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1485)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at HelloWorld.<clinit>(HelloWorld.java:15)

No idea what this means although I suspect it has something to do with the
compilation of HelloWorldImp.c.
What have I done ( or not ) as the case may be.

Thanx.....

IBM

__________________________________________________ _____________________________
Posted Via Uncensored-News.Com - Accounts Starting At $6.95 - http://www.uncensored-news.com
<><><><><><><> The Worlds Uncensored News Source <><><><><><><><>

Jul 17 '05 #1
2 2248
On Fri, 26 Mar 2004 23:25:43 +0000, ian maclure wrote:

I'm trying to understand JNI well enough to be be able to supply
a state model class in C++ to some client applications and use the
same model in the JAVA app that controls the clients.
[snip]
ZZZZ=HelloWorldImp.c
JJJJ=/usr/java/sdk ( 1.4.2_01 as it happens )
CPPOPT="-c -g -shared"
gcc $CPPOPT -I$JJJJ/include -I$JJJJ/include/linux $ZZZZ -o libhello.so


Problem was the "-c" in CPPOPT. Just run the preceding with
CPPOPT=shared and things work.

IBM

__________________________________________________ _____________________________
Posted Via Uncensored-News.Com - Accounts Starting At $6.95 - http://www.uncensored-news.com
<><><><><><><> The Worlds Uncensored News Source <><><><><><><><>

Jul 17 '05 #2
You might want to include -fPic flag as well if you want position
independent code.

"ian maclure" <ib*@svpal.org> wrote in message
news:pa****************************@svpal.org...
On Fri, 26 Mar 2004 23:25:43 +0000, ian maclure wrote:

I'm trying to understand JNI well enough to be be able to supply
a state model class in C++ to some client applications and use the
same model in the JAVA app that controls the clients.
[snip]
ZZZZ=HelloWorldImp.c
JJJJ=/usr/java/sdk ( 1.4.2_01 as it happens )
CPPOPT="-c -g -shared"
gcc $CPPOPT -I$JJJJ/include -I$JJJJ/include/linux $ZZZZ -o

libhello.so
Problem was the "-c" in CPPOPT. Just run the preceding with
CPPOPT=shared and things work.

IBM

__________________________________________________ __________________________
___ Posted Via Uncensored-News.Com - Accounts Starting At $6.95 - http://www.uncensored-news.com <><><><><><><> The Worlds Uncensored News Source <><><><><><><><>

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Frank Stephan | last post by:
Hi, im using Struts with nested tags for form validation. So I end up with form elements named like this risikenManuell.praemieNeu risikenManuell.praemieNeu .... I would like to do a...
2
by: Michelle Marie | last post by:
I have several forms stored in pdf format. Instead of scanning these forms and using them in reports, I would like to create a background in an access report to place the fields but have it...
5
by: Tom Gao | last post by:
Hello friends I'm trying to perform event bubble on a user control from the example on http://odetocode.com/Articles/94.aspx but this example doesn't work... when I run the code it says...
0
by: Aleksey Loginov | last post by:
http://thc.org/root/phun/unmaintain.html
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
63
RedSon
by: RedSon | last post by:
Where do you put it? Like this if (...){ //blah blah } or like this
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.