Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7905767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:35:35+00:00 2026-06-03T10:35:35+00:00

Java Code : package Package; public class IntArray { private native int sumArray(int[] arr);

  • 0

Java Code :

package Package;

public class IntArray {
private native int sumArray(int[] arr);

public static void main(String args[]) {
    IntArray p = new IntArray();
    int arr[] = new int[10];
    for(int i=0 ; i<10 ; i++) {
        arr[i] = i;
    }
    int sum = p.sumArray(arr); // pass the array to the c function sumArray
    System.out.println("Sum is : " + sum);
}

 static { // 17th statement
     System.loadLibrary("IntArray");
 }
}

C code :

#include<stdio.h>
#include "Package_IntArray.h"

jint Java_Package_IntArray_sumArray(JNIEnv *env, jobject obj, jintArray arr)
          {
             jint buf[10];
             jint i, sum = 0;
             (*env)->GetIntArrayRegion(env, arr, 0, 10, buf);
             for (i = 0; i < 10; i++) {
                 sum += buf[i];
             }
             return sum;
          }

Then i run the command :

java -Djava.library.path=W:\elita\jnitesters\workspace\c\IntArray\bin\Debug Package.IntArray

to which i get the following exceptions :

Exception in thread "main" java.lang.UnsatisfiedLinkError: Package.IntArray.sumArray([I)I
    at Package.IntArray.sumArray(Native Method)
    at Package.IntArray.main(IntArray.java:17)

There is a dll file named IntArray.dll in the directory W:\elita\jnitesters\workspace\c\IntArray\bin\Debug

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:35:38+00:00Added an answer on June 3, 2026 at 10:35 am

    Everything is fine ! But there is one thing you should attempt. Permanently delete all sorts of files(including .dll file) created by the IDE code::blocks . And then rebuild your program. Omit MACROS if any ! Then it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code: package Prova; import java.util.ArrayList; public class Prova { private ArrayList<String> people;
Here's the code: package testpack; import java.io.*; public class InputStreamReadDemo { private void readByte()
The following is my ProtectedConstructor.java source code: package protectCon; public class ProtectedConstructor{ public int
I've got the following simple code: package main; import java.util.concurrent.*; public class Main {
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
Here is the server code package echoserver; import java.net.*; import java.io.*; public class EchoServer
This is my code: package test; import java.util.logging.Level; import java.util.logging.Logger; class Data{ int ar[]=new
My directory structure is: ABC/src/com/example/model/a.java ABC/src/com/example/web/b.java Code for a.java : package com.example.model; public class
Java Source Code: package n1_problem; /** * * @author nAwS */ public class loop
Java applet code package M257Applet import java.applet.*; import javax.swing.*; import java.awt.*; public class HellowApplet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.