Can't get the java DDS example to run

10 posts / 0 new
Last post
Gan
Offline
Last seen: 8 years 11 months ago
Joined: 08/08/2014
Posts: 17
Can't get the java DDS example to run

I'm testing out the new version of DDS and it isn't running for me.

I've been following the documentation for setup and running the example pub sub java program. It built fine but running produced this error:

C:\Program Files\rti_connext_dds-5.2.0\resource\template\rti_workspace\examples\connext_dds\java\hello_simple>"C:\Program Files\rti_connext_dds-5.2.0\resource\template\rti_workspace\examples\connext_dds\java\hello_simple\runPub.cmd" The library nddsjava.dll could not be loaded by Windows. Make sure that the library is in your Path environment variable. Exception in thread "main" java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source) at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source) at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source) at com.rti.simple.HelloPublisher.main(HelloPublisher.java:29)

According to the error it can't find nddsjava.dll in the path variable. Here's my %path%:

C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Matt\.posh_gvm\griffon\current;"C:\Program Files\rti_connext_dds-5.2.0\lib\java";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsjava.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddscore.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsc.dll";"C:\Program Files\rti_connext_dds-5.2.0\bin";"C:\Program Files\Java\jdk1.8.0_65\bin"

Little messy because I've been trying to solve this bug on my own for a while. I also have NDDSHOME set.

Any idea how to fix this?

Fernando Garcia's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 05/18/2011
Posts: 200

Hi Gan,

Can you try to run the Java application by hand, I think the runPub.cmd script modifies your path already and is doing something funny with it. To run the application manually just do:

"C:\Program Files\Java\jdk1.8.0_65\bin\java.exe" -classpath objs;"C:\Program Files\rti_connext_dds-5.2.0\lib\java\nddsjava.jar" com.rti.simple.HelloPublisher

Assuming that  "C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013" contains all the DDS libraries (i.e., you installed that target) it should work. Note that you only need to add that directory to your path, it will automatically find there all the .dll files, so you do not need to add these to your path.

Please, let me know if this works and we can try to find identify problem in the runPub.cmd file.

Thanks,
Fernando.

Gerardo Pardo's picture
Offline
Last seen: 1 week 1 day ago
Joined: 06/02/2010
Posts: 602

Hi Gan,

In addition to Fernando's comments I was wondering if your plaform is 32 bits or 64 bits. It appears like your PATH mixes 32-bit and 64 bit libraries. If your system (or VM) is 32 bit then you would not be able to load the libraries from x64Win64VS2013 which are for 64 bits.

The other thing that comes to mind are the Visual Studio redistributables.  These are Microsoft libraries that are required in your system if you are loading a DLL which was compiled with Visual Studio (which the Connext DDS DLLs were).  You can read more details on which ones are required and how to install them from the RTI Connext DDS Windows Platform Notes here

If the above fails another thing you might want to try is to install the dependencywalker  tool which will allow you to see which libraries the nddsjava.dll depens on and whether they can be found in your system.

Gerardo

Gan
Offline
Last seen: 8 years 11 months ago
Joined: 08/08/2014
Posts: 17

I tried all of your suggestions(which are very good by the way) and I'm still having issues. I attached a screenshot of the dependency application. Apparently there's a lot of missing dependencies.

Could the problem be that I'm running Windows 10?

I am 64 bit but RTI 64 bit always wants to install in the normal Program Files folder.

Fernando Garcia's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 05/18/2011
Posts: 200

Hi Gan,

I think you may be missing the Visual C++ redistributable packages for Visual Studio 2013 (see this question on Stack Overflow). You can download these redistributable packages from Microsoft's website. In particular, you will probably want to download vcredist_x64.exe

Let us know if this fixes at least the missing dependencies that dependency walker is showing.

Thanks,
Fernando.

Gan
Offline
Last seen: 8 years 11 months ago
Joined: 08/08/2014
Posts: 17

I already had that installed so I repaired it using the installer. The dependency walker still shows all the same problems when I open nddsjava.dll. I even installed Visual Studio 2015 to see if that'd help. But it didn't.

I tested the C-Sharp Simple Pub Sub example and it works perfectly. The java version still doesn't work for me. The java example still outputs: 

 

Exception in thread "main" java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source) at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source) at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source) at com.rti.simple.HelloPublisher.main(HelloPublisher.java:29)

I'll continue googling.

Gan
Offline
Last seen: 8 years 11 months ago
Joined: 08/08/2014
Posts: 17

 

 

String libpath = System.getProperty("java.library.path");

libpath = libpath + ";C:\\Program Files\\rti_connext_dds-5.2.0\\lib\\x64Win64VS2013\\";

System.setProperty("java.library.path",libpath); System.out.println("");

System.out.println("Java.library.path : ");

System.out.println(System.getProperty("java.library.path"));

System.out.println("");

System.loadLibrary("nddsjava.dll");

 

I ran this code and it outputted this:
 

Java.library.path :

C:\ProgramData\Oracle\Java\javapath;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Matt\.posh_gvm\griffon\current;"C:\Program Files\rti_connext_dds-5.2.0\lib\java";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsjava.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddscore.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsc.dll";"C:\Program Files\rti_connext_dds-5.2.0\bin";"C:\Program Files\Java\jdk1.8.0_65\bin";C:\Users\Matt\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;.;C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\

Exception in thread "main" java.lang.UnsatisfiedLinkError:

no nddsjava.dll in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.rti.hello.builtin.Hello.main(Hello.java:303)

I am so confused. Why can't it find the DLL? 
 
Oh wait haha. You can't modify java.library.path in the execution. It sitll only searches what it was previously.
 
Just re-did it with this code:
 

System.out.println("Java.library.path : ");

System.out.println(System.getProperty("java.library.path"));

System.out.println("");

System.load("C:\\Program Files\\rti_connext_dds-5.2.0\\lib\\x64Win64VS2013\\nddsjava.dll");

It outputs:
 

Java.library.path :

C:\ProgramData\Oracle\Java\javapath;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Users\Matt\.posh_gvm\griffon\current;"C:\Program Files\rti_connext_dds-5.2.0\lib\java";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsjava.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddscore.dll";"C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsc.dll";"C:\Program Files\rti_connext_dds-5.2.0\bin";"C:\Program Files\Java\jdk1.8.0_65\bin";C:\Users\Matt\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;.;C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\

Exception in thread "main" java.lang.UnsatisfiedLinkError:

C:\Program Files\rti_connext_dds-5.2.0\lib\x64Win64VS2013\nddsjava.dll:

Can't find dependent libraries at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at java.lang.System.load(Unknown Source) at com.rti.hello.builtin.Hello.main(Hello.java:303)

Alright, step closer. It finds the DLL but why can't it find the DLL's dependencies? Dependency Walker seems to be outdated and only tells me about a bunch of API-WIN-CORE missing dependencies.
Gan
Offline
Last seen: 8 years 11 months ago
Joined: 08/08/2014
Posts: 17

Fixed it. I'm sure it was multiple issues but the last thing I did was change my path variable to include C:\Program Files\rti_connext_dds-5.2.0\. Also made sure all quotation marks were removed from my path variable.

Offline
Last seen: 6 years 11 months ago
Joined: 11/29/2017
Posts: 1

A similar problem is occuring with me Although  i have set the path variable it is unable to load the nddsjava.dll . I am using Eclipse . My code is working on Java 9 but when I downgrade it to lower version(Java8) this message pops up 

The library nddsjava.dll could not be loaded by Windows.
Make sure that the library is in your Path environment variable.
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\rti_connext_dds-5.3.0\lib\x64Win64VS2015\nddsjava.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source)
at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source)
at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source)
at HelloWorldPublisher.publisherMain(HelloWorldPublisher.java:124)
at HelloWorldPublisher.main(HelloWorldPublisher.java:94)

 

gb1
Offline
Last seen: 6 years 4 months ago
Joined: 06/26/2018
Posts: 1

Just passing along that I also had a problem with an application needing nddsjava.dll throwing a 'can't load' error.  Adding the folder location of the DLL to the end of the Windows path didn't solve the problem.  However, adding it to the FRONT of the path did.