• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNI + Error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am trying to use jni for making a call to a existing C function thru Java
Now I have started to learn the same .
I have written a small java program called NativeApp.java :- source code is
--------------------------------------------------
class NativeApp {
public static void main(String[] args){
if (args.length!=1){
System.out.println("Usage:java NativeApp n");
System.exit(0);
}
int n = new Integer(args[0]).intValue();
int answer=new Native().fibonacci(n);
System.out.println(answer);
}
}
--------------------------------------------------
and the corrosponding Native Class Souce code is :-
--------------------------------------------------
class Native
{
public native int fibonacci(int n) ;
static
{
System.loadLibrary("Native");
}
}
--------------------------------------------------
Then I have used the javah -jni Native Command to make the header file.(Successful)
My Os is Solaris and the jdk is 1.2 .
When I try to make the shared library using the following commnad :-
--------------------------------------------------
cc -G -I/fullpath of directory/taxware -I/java/jdk1.1.8/include -I/java/jdk1.1.8/include/solaris NativeImp.c -o Partha.so
--------------------------------------------------
however this gives a error
--------------------------------------------------
Warning: Option -YP,:/usr/ucblib:/opt/SUNWspro/WS6U2/bin/../lib:/opt/SUNW
spro/WS6U2/bin:/usr/ccs/lib:/usr/lib passed to ld, if ld is invoked, ignored oth
erwise
"/user1/xpd2/taxware/jni_md.h", line 24: warning: signed is a keyword in ANSI C
"/user1/xpd2/taxware/jni_md.h", line 24: syntax error before or at: char
"/user1/xpd2/taxware/jni.h", line 107: syntax error before or at: jbyte
"/user1/xpd2/taxware/jni.h", line 107: cannot recover from previous errors
--------------------------------------------------
Can Someone please help me out ?
Thanking you in Anticipation
Partha
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would help to see the C code that was generated, since this is a C compiler error that you're getting.
I'll move this over the Other APIs, since it's not related to distributed computing.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
chatterjee_parth,
like Michael said, this looks like a C compiler error, so I can't be of much help. Sorry.
Also, your name is almost keeping with our JavaRanch naming standards, but not quite; if you replaced the underscore "_" with just a space you would be fine.
Please change your name to comply with the naming policy to which you agreed when you registered here..


For your publicly displayed name,
use a first name, a space, and a last name.


You can change your name here:
here

You can also find the naming policy here:
http://www.javaranch.com/name.jsp
Thank You!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic