- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem with Java JNI Java and C
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2012 01:31 PM
01-19-2012 01:31 PM
Problem with Java JNI Java and C
Hi,
I need a Java program to call a C program (not C++). I’m following the instructions on HP-UX Programmer's Guide for Java™ 2. However, it doesn’t work. Here are the Java and platform versions:
$uname –mr
B.11.31 ia64
java –version
java version "1.6.0.11"
Java(TM) SE Runtime Environment (build 1.6.0.11-jinteg_14_jul_2011_03_07-b00)
Java HotSpot(TM) Server VM (build 20.1-b02-jre1.6.0.11-rc2b1, mixed mode)
It compiles and builds the library fine and I do set SHLIB_PATH to the directory of the library. I compile:
cc -Ae +u4 +z -c -D_HPUX \
> -I/opt/java6/include -I/opt/java6/include/hp-ux -I./ \
> myProg.c
And build the shared lib as either:
aCC -b -o myProg.so myProg.o \
-lstd -lstream -lCsup -lm
(tried it also with cc)
Or as:
ld -b -o myProg.so myProg.o
And tried some other options. But always when I run the Java program that calls this C program I get:
java.lang.UnsatisfiedLinkError: no myProg in java.library.path
Can someone point the exact compile and library build commands for this platform and Java version? I did test the Java Property and verified the directory of the shared library is there.
Thanks.
- Tags:
- JNI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2012 09:42 PM
01-19-2012 09:42 PM
Re: Problem with Java JNI Java and C
>And build the shared lib as either:
aCC -b -o myProg.so myProg.o -lstd -lstream -lCsup -lm
This is incorrect, I thought I got them to change it.
For Integrity, -AA:
aCC -b -o libmyProg.so myProg.o -lstd_v2 -lCsup -lunwind -lm
>(tried it also with cc)
You shouldn't really be using ld:
cc -b -o libmyProg.so myProg.o
>Can someone point the exact compile and library build commands for this platform and Java version?
I think the key point is that you have to have the "lib" prefix and the ".so" suffix.
I'm not sure what step needs the "export CLASSPATH=..."?