Please, every help will be appreciated. I am stuck with this samples, try about ten different samples from the net, and still have not been made one of them working ... It is important for me to make one of them working because I am new in JNI and reading something like book about it but in the book everything is done in eclipse and to continue with the reading I have to understand how to make the samples there in NetBeans IDE.

Thanks in advance.

EDIT: I was not given to extract the code. I message tells my : " Sorry, this content is not allowed " ... I will try to past it somehow...

I have not succeedеd to add the main class but it is able to be seen in the sample link. I have searched the net for the error and understood that it is about bad linking. I have try to apply some methods for solving my problem.

1) I have created new projects in order to have path without space

2) I have add the path to my .so object in the Virtual Machine options

3) I have used the method load library instead load.

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

This is the error message I have been given after building the project:

run:
java.lang.UnsatisfiedLinkError: no libHelloWorldC in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at helloworld.Main.<clinit>(Main.java:16)
Could not find the main class: helloworld.Main. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Has anyone idea what other method I can try in order to fix the problem or what is the root of the problem itself?

Thanks in advance.

Edited by: gotqn on Feb 27, 2011 5:28 PM

Edited by: gotqn on Feb 27, 2011 5:29 PM

Edited by: gotqn on Feb 27, 2011 5:29 PM

Edited by: gotqn on Feb 27, 2011 5:30 PM

Edited by: gotqn on Feb 27, 2011 5:30 PM

Edited by: gotqn on Feb 27, 2011 5:31 PM

Edit: I am not given to show you my pathways in point 1) and 2) - why I am stopped by the system to publish them?

Edited by: gotqn on Feb 27, 2011 5:31 PM

Edited by: gotqn on Feb 27, 2011 7:13 PM

Edit: Can anyone tell me what's the difference in Java Native Interface when we are creating .dll object and .so object?

You are getting this after loading the library, when actually calling the method. So the method signature doesn't agree with what Java is expecting. This can happen when copying code if for example you change the Java class or package name after running javah. You would have to post the Java native method signature and your .h file. The system should let you do both of those.

Thanks for the answer. I am not using javah because I have problem with it. I am using JNI stub program - it has been add to NetBeans IDE and I can generate .h file just with two clicks on the class.

You were wrong I am not able to post my code. This is link with the three pictures - on main clas, on header file, on method - you are able to view them online (firstly, they are not good to be seen, but click on one of them and they will be open in separate window and been very easy to be seen even three at the same time.

I am very sorry, but I am not able to past the code, and I am not tell what's wrong with it. Please, check my code for the error and for the reason the system do not let me publish my code.

gotqn wrote:
Thanks for the answer. I am not using javah because I have problem with it. I am using JNI stub program - it has been add to NetBeans IDE and I can generate .h file just with two clicks on the class.

It doesn't matter how it runs as long as it does run and then you use the result. Using the result is not automatic. It is something that you must manually do.

You were wrong I am not able to post my code. This is link with the three pictures - on main clas, on header file, on method - you are able to view them online (firstly, they are not good to be seen, but click on one of them and they will be open in separate window and been very easy to be seen even three at the same time.

Start with a SMALL example.

No one wants to see your entire application. And I for one will not look at it. Nor will I click on links.

jshell, thanks for the answers, I understand that you do not want to click on links that may make to go to unsecured areas in the net ... It is a kind of insulting because I have just wanted to be helped, not to the something bad to people I do not know. Anyway, this is your right and I respect it.

It is very useless for me that I am not able to post my code and at the same time I am not said what is wrong with it. My code is not something big, we are talking about my first Java Native Interface program. It includes only few lines.

I really need help, so I will try to post anything it is possible.

This is part of java class main. I am not able to past the static load method, so I have to describe it: "I am adding the path way in the project VM options filed and I use load library adding only the name of the object without its extension."

The difference is that .so files are for Linux, Unix, Solaris, AIX, etc, and .dll files are for Windows.

and what's better to be used.

That's meaningless. There's no 'better' about it. You don't get the choice. The platform dictates which one you have to use. The purpose of System.loadLibrary is to shield you from the issues of where it actually is and whether it is a .so or a .dll. So use that. And install the shared library in '.' as I said above.

This is what I have done:
1. Open C/C++ project , changed the linker output as ./libHelloWorldC.dll .
2. Build and Clean.
3. Have the dll in the project directory, not in the dist folder of the project.
4. Changed the java project VM option to -Djava.library.path=C:\NetBeansProjects\HelloWorldC
5. Run... the same erorr