It is currently Thu, 25 Feb 2021 07:20:19 GMT



 
Author Message
 jni-Application (gcc)
Hello !

I'm trying to write my first java-application, which uses the jni-interface, but
it doesn't run.
Has anyone an idea, whats my problem ?
Especially, how do i have to call the gcc.

Thanks for every hint.

Raimund.Mic...@de.abb.com

1) Hello.java
-------------
class Hello
{
  // ====== main =======================
  public static void main(String[] args)
  {
     new Hello().displayHello();
  } /* end main */

  public native void displayHello();

  static
  {
     System.loadLibrary("hello");
  }

java Hello.java
javah -jni Hello

2) Hello.h
----------
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Hello */

#ifndef _Included_Hello
#define _Included_Hello
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     Hello
 * Method:    displayHello
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_Hello_displayHello
  (JNIEnv *, jobject);

#ifdef __cplusplus
#endif
#endif

3) Hello.c
----------
#include "Hello.h"
#include <stdio.h>

JNIEXPORT void JNICALL Java_Hello_displayHello (JNIEnv *env, jobject obj)
{
   printf("Hello World\n");
   return;

gcc -Wall -shared -I /usr/jdk_base/include/
-I /usr/jdk_base/include/aix Hello.c -o libhello.so

java Hello
SIGSEGV received at 20147010 in . Processing terminated
Writing stack trace to javacore.txt ... OK
IOT trap (core dumped)

--
Posted from gifdns1.abb.de [138.222.152.123]
via Mailgate.ORG Server - http://www.**-**.com/



 Fri, 18 Jul 2003 21:19:06 GMT   
 jni-Application (gcc)
On 29 Jan 2001 14:19:06 +0100, raimund.mic...@de.abb.com <raimund.mic...@de.abb.com> wrote:

[snipped sample code]

You will have to link against the threaded versions of the C library,
look into the JDK directory as installed on AIX, there is an jni_sample
directory and there a c subdirectory with a C example. This sample uses
a fairly complicated ld command line to link a java native extension.

--
Jens-Uwe Mager  <pgp-mailto:62CFDB25>



 Sat, 19 Jul 2003 08:02:51 GMT   
 
   [ 2 post ] 

Similar Threads

1. Need help on SIGSEGV error in a g++/JNI application

2. JNI shared library and gcc

3. JNI on AIX using gcc

4. GCC-built application performance on Solaris...

5. Compiling 32 bit applications on Solaris 8 using cc or gcc

6. Intalling X Applications With Gcc Under Solaris 2 OpenWindows

7. Installing X Applications With GCC Under Solaris 2 OpenWindows

8. gcc-pentium and applications

9. How to build application for 64bit solaris8 on SPARC with gcc

10. using iptables programicly (jni)


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software