Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

JNI + Error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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!
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic