I want to use JMatLink to connect Java with Matlab. I need to use this specific library since it is integrated in the projeny code. I have followed the steps from the documentation / other forums:
downloaded the source code from sourceforge
unzipped it
copied the JMatLink.dll into C:\Windows\System32
added the path of matlab\bin and matlab\bin\win64 to my system environment variables
However, when I try to run the class SimpleGuiTest, I get the following error message:
ERROR: Could not load the JMatLink library
Win: This error occures, if the path to
MATLAB's <matlab>\bin directory is
not set properly.
Or if JMatLink.dll is not found.
Linux: Check if <matlab>/extern/lib/glnx86 (libeng.so, libmat.so, etc.)
and <matlab>/sys/os/glnx86 (libstdc++-libc6.1-2.so.3) are in your path.
(you can also copy missing libraries to your local path).
and
Exception in thread "main" java.lang.UnsatisfiedLinkError: jmatlink.CoreJMatLink.setDebugNATIVE(Z)V
I have changed the code where the library gets loaded from
System.loadLibrary("JMatLink");
To a command with absolute path
System.load("C:\\Windows\\System32\\JMatLink.dll");
But I am still getting the same error message. Is it possible that the .dll is not compatible with my Win 8.1 and Matlab R2014a environment? Do I have to compile a new one for my environment? Or is there anything else that I am missing?
I've also tried to install it without any luck a while back. I belive the reason is, as you state, that the .dll is not compatible with 64-bit operating systems/Matlab. If I remember correctly, a few of the dependencies it requires some 32-bit system libraries which was not found in my version of Windows 7 (64-bit). To map the missing dependencies I used dependencies-walker.
I had a go at compiling the source code as well, but you need to have an older version of Matlab6.5 (according to the build file) in order to compile it with the accompanying build file. More modern versions of Matlab such as 2014a does not have support for the aging borland compiler used by the build file. When trying to compile the library with Borland 5.5.1, MatlabR2012b, JavaSE1.4.2 it gives me the error:
compile:
[exec] Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
[exec] Error E2194: Could not find file 'Files\MATLAB\R2012b\extern\include.cpp'
[exec] Error E2194: Could not find file 'Files\MATLAB\R2012b\simulink\include.cpp'
It might be that you can find a way to build it with a modern supported compiler or if you get your hands on an older version of Matlab, but at this point I gave up that approached and created a wrapper using the matlabcontrol-fork matconsolectl.
Hope my experience has been helpful in some way.
Related
I am new to Java. I am taking a University beginners Java course. I'm running my first hello world code and am getting an error message. I have installed the latest Dr. Java stable version and have installed Java SE 12 JDK.
I have uninstalled and reinstalled Dr. Java several times and still getting error message. I have also recompiled it to and still the error message is there.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
I expected the code output to say, "Hello World" under the interactions pane but it isn't and instead there is an error message that says, "Current document is out of sync with the Interactions Pane and should be recompiled!".
Also, under the console pane I receive the following message:
Compiler is using classPath = '[C:\Users\Admin,
C:\Users\Admin\Downloads\drjava-beta-20190813-220051.jar]';
bootClassPath = 'null' Fatal Error: Unable to find package java.lang
in classpath or bootclasspath
Realizing that the OP solved his problem by version of JDK, I ran across this question after experiencing the same symptoms he describes. With that, it seems possibly appropriate to post a solution for the symptoms even though the problem ended up not being quite "identical" to the OP's situation:
I had the same problem with compilation not working. In my case, I am using a Linux system that has both OpenJDK and a manually installed Oracle JDK (extracted from a tarball obtained from java.com), along with some other JRE environments in various places. I "installed" the DrJava Version : drjava-20190813-220051 jar file and ran it from the command-line. I then clicked [ Manual Download ] when it asked about installing updates (drjava-beta-2019-220051).
DrJava reported that my compiler was JDK 8.0_222. Note, I don't know where that compiler came from. As far as I know, I didn't have that version installed. My OpenJDK was:
$ /bin/java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
I typed in a simple "Hello World" program, and every attempt to compile produced:
Compiler Output:
"Compilation completed."
This is a bug, because in fact compilation apparently did not complete.
Clicking Run produced:
Interactions
Welcome to DrJava. Working directory is /home/krb/Projects/Software/java
Current document is out of sync with the Interactions Pane and should be recompiled!
>
Restarting DrJava, saving, clicking Reset, etc., would not clear the problem.
In any event, at some point I noticed the Console tab was full of messages like:
Console
Compiler is using classPath = '[/home/krb/Projects/Software/java, /home/apps/drjava/drjava-beta-20190813-220051.jar]'; bootClassPath = 'null'
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
At this point, I tried various things, but I focused on pointing DrJava to an Oracle Java JDK I had installed a few days ago. Everything I did was in Edit | Preferences ... | Resource Locations, though I beat around in there a while. All of the settings were "blank" before I started. Anyway, I eventually had some success after I'd set:
Web Browser
/usr/lib64/firefox/firefox
Web Browser Command
Tools.jar Location
/home/raid/apps/oracle/jdk-1.8.0_251/jre/lib/tools.jar
Display All Compiler Version [ ]
Extra Classpath
/home/raid/apps/oracle/jdk1.8.0_251/jre/lib
/home/raid/apps/oracle/jdk1.8.0_251/lib
NOTE: Your PATHs will NOT be the same as mine! You need to use the
actual paths on your system. In my case I searched for "rt.jar" and
"tools.jar" that were obviously in folders related to an installed
JDK.
At this point I decided to try to figure out the minimum required to get it working. After a lot of fiddling around, I found it is sufficient just to set Preferences | Resource Locations | Tools.jar Location, but with with one MAJOR caveat. You must BROWSE to the file using that dialog. YOU CANNOT JUST PASTE IN THE PATH! If you just paste in the path, it can look like it is set correctly, but the compiler will continue to not work. This was how I got the oracle jdk compiler to work.
Next, I set about to see if I could get OpenJDK to work. I searched my entire system for another tools.jar that belonged to OpenJDK, and did not find one. Then I realized I did not have the DEVEL OpenJDK package installed (on Mageia Linux 7).
java-1.8.0-openjdk-headless-1.8.0.252-1.b09.1.mga7
java-1.8.0-openjdk-1.8.0.252-1.b09.1.mga7
I installed:
java-1.8.0-openjdk-devel-1.8.0.252-1.b09.1.mga7
Now, even after resetting defaults, DrJava no longer says it is using JDK 8.0_222, but rather JDK 8.0-openjdk-1.8.0.252-1.b09.1.mga7.x86_64-OpenJDK, and everything works fine with NO customization to preferences!
I don't know where the heck JDK 8.0_222 came from. There's nothing on my system with that version. I rather suppose it is some internal thing in DrJava. I think the takeaways are:
If DrJava says its using JDK 8.0_222, it probably is not going to work!
Make sure you actually have a tools.jar installed if your system might split up the OpenJDK installation.
Point Tools.jar Location to an existing tools.jar file where the JDK you are using is installed, and making sure to browse to it (not just paste in a path).
I know what I saw was with Linux and a .jar install of DrJava, and this might not be what you have, but perhaps the information will be helpful in offering you things to look at and try.
As the answers above state, DrJava is not compatible with newer versions of Java than Java 8. Most of the DrJava codebase was written long before the open source version of Java was viable. The Sun Microsystems and Oracle javac compilers are proprietary and cannot be distributed with open source apps like DrJava. So DrJava searches for tools.jar (the library file containing the compiler in Java JDK distributions prior to Java 9) in common locations on Windows, Mac OS X, and Linux to find a compiler (more accurately, what were common locations in 2007). If you are running DrJava from a Java 8 JDK, it almost always finds it (although it appears to be failing for some installations Amazon Corretto 8). The most recent available build (March 3, 2020) of DrJava at www.cs.rice.edu/~javaplt/drjavarice may do a better job. I know it includes a later version the open source Java 8 compiler (JDK 8.0_242) and that it also finds the compiler (JDK 8.0_265) in the Corretto 8 distribution that I am using on Windows 10. The mysterious version of the open source JDK compiler reported above is being retrieved from the drjava.jar file itself. Now that the open source JDK includes a reliable compiler (which I suspect is nearly identical to the Oracle Java 8 SE compiler), the drjava.jar file includes a recent build of the open source Java 8 compiler.
Your solution helped me troubleshoot a problem with DrJava not recognizing the Amazon Carretta JDK on a Mac.
The fix is to open DrJava and go to Edit -> Preferences -> Resource Locations. From the Tools.jar Location box you must use the three dots at the end of that box to navigate to the tools.jar file on your Mac, which is probably in /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/lib/tools.jar.
I compiled C++ code with gcc 4.8.2 (which is c++11 version and it is necessary for my C++ code) and generated a libmy.so file. I want to call the method in libmy.so from Java code with JNI, and I have set LD_LIBRARY_PATH to be the path of libmy.so. When run Java code, errors info is like below:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
.../libmy.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not
found (required by libmy.so)
Because this Linux machine is common used, I don't want to modify files in /usr/lib64 (e.g., modify the link of libstdc++.so.6).
By the way, my JDK version is 1.8, I tried JDK 1.11 and it also failed.
It seems that Java can't load the right version of libstdc++.so.6 (also for libc.so), but I am not sure.
How to fix this problem? Thanks a lot!
UPDATE: See the solution in Caleb's answer
I am trying really hard to make Coverity work for my build, but so far with little success.
First the details:
My project is run of the mill java library (no web or fancy containers), very few compile-only dependencies, built using Gradle
The production code is written in Java and Kotlin
The complete project is available on github: https://github.com/ddimtirov/nuggets
And on Coverity Scan: https://scan.coverity.com/projects/ddimtirov-nuggets?tab=project_settings
My development environment is Windows 10, Java 1.8.0_92, Gradle 3.3, CMD shell (though I also tried Cygwin and Mingw Bash)
there is also Travis build on Linux
I started by downloading a package from: https://scan.coverity.com/download/java/win64
Then I added the bin directory to my path, went to my project root and ran the following commands.
$ set PATH=%PATH%;C:\Users\dimit\sandbox\cov-analysis\bin
$ gradlew clean
$ cov-build --dir cov-int gradlew jar
The first 2 went as expected, the last - not so much:
Coverity Build Capture (32-bit) version 8.7.0 on Windows 10 Professional, 64-bit (build 14393)
Internal version numbers: b452b3f2c8 p-lodi-push-28091.612
The system cannot execute the specified program.
[WARNING] Build command gradlew.bat jar exited with code 1. Please verify that the build completed successfully.
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
C:/Users/dimit/sandbox/nuggets/cov-int/build-log.txt
I have put the build log here: https://gist.github.com/ddimtirov/9daa0e9f1f0954453f01fcec42ae2198
The "Troubleshoot build failure" on the instructions page was pointing to a forum index page, which does not help at all: https://software-community-synopsys.force.com/s/#4838
Moving on, I thought that if I could only generate the data in some other way I could upload it to the scan service and bypass the problem. I found https://github.com/mjdetullio/gradle-coverity-plugin
The Gradle Coverity plugin emitted the data, but when I zipped it and uploaded to the scan service, it barfed the error email.
As last resort, I tried the TravisCI integration - after a few attempts, I got it to complete without an error, but it didn't seem to upload anything...
https://travis-ci.org/ddimtirov/nuggets/builds/196307253
https://scan.coverity.com/projects/ddimtirov-nuggets?tab=overview
I am close to giving up (BTW, not having docs available online doesn't help)
Issue 1 - "The system cannot execute the specified program."
This issue arose because a Windows 32-bit kit was used to attempt to capture a Windows 64-bit build. The attempt to attach a 32-bit process to a 64-bit one causes failure to execute.
The solution here is to match the bitness of Coverity binaries with the bitness of your platform (use a Windows 64-bit kit).
Issue 2 - Failure to capture TravisCI build on Linux
This issue appears to be due to an incompatibility between Coverity's Java Capture and the ErrorProne plugin, as evidenced by messages such as this one in the build log:
WARNING: Failed load class file java/io/FileNotFoundException.class as a resource using the class loader net.ltgt.gradle.errorprone.ErrorProneCompiler$SelfFirstClassLoader#36358417
The solution here is to disable that plugin for the Coverity build.
Varia
When debugging the issue, the known issue of the Gradle daemon interfering with Coverity was discussed, but was ultimately not relevant to the issue.
The noted issues with the "prepend" command are user error; the prepend command is not a separate command to run, it's there for utility purposes.
A few things to note, because reading our documentation is crucial to using our tool successfully:
Kotlin is not supported.
Using the appropriate binaries for your platform is required (so using win32 binaries on a 64 bit platform will generally not work).
I am exploring a trial version of Adobe's Technical Communication Suite. Following this video, I am trying to generate an Android app using a sample document.
I've tried changing the file paths for the JDK and apache.ant files, but keep receiving the same error message (see below).
BUILD FAILED
C:\Program Files (x86)\Android\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:713: The following error occurred while executing this line:
C:\Program Files (x86)\Android\adt-bundle-windows-x86_64-20130522\sdk\tools\ant\build.xml:727: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files (x86)\Java\jre7"
I got the same error but in a linux system and solved it by knowing that: JDK is a super command for JRE.
JRE: Java Runtime Environment only runs not compile or build (eg. using ant).
JDK: compiles and runs.
So try changing your java setting to JAVA_HOME= ..../java OR .../jdk not .../jre.
It seems that you didn't configure your JAVA variable environment.
BTW, I don't know what IDE you are using. As far as I know, if you have more than one java versions in your computer, in eclipse you should set variables.
(1) window->preference-> left column (Java)->Compiler, you could change different compiler version.
(2) And in left column (Java) -> Installed JRE, you should also modify the JRE version.
I used the Matlab deployment tool to build a matlab code into a java project. I am having some problem with the Matlab-Java interface, the error while running the java code is:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to
find the library mclmcrrt7_15.dll, required by MATLAB Builder JA, on
java.library.path. This library is typically installed along with
MATLAB or the MCR, its absence may indicate an issue with that
installation or the current path configuration.The MCR version that
this component is trying to use is: 7.15.
When I type "version -java" in the Matlab console, the answer is Java 1.6.0_17-b04. So,I changed my Path in the system settings to ...\Files\Java\jdk1.6.0_33\bin But since I have Java version-7 installed, It is not using version-6. In command prompt, when I checked the version of java and javac, I saw that the version of javac is 1.6 but that of java is 1.7. I also made a CLASSPATH environment variable and a JAVAHOME variable and set it to 1.6. Could you please tell me how do I change the java version being used by the system to 1.6 so that matlab can interact with it?
I think this is the problem, but I am just guessing from the error message. Please let me know if the problem is something else, and not just the incompatibility in java versions.
Is the DLL mclmcrrt7_15.dll on the PATH anywhere?
For Java to be able to load a DLL, the DLL needs to be in a folder listed in the java.library.path system property. The default value for this property on Windows is the PATH environment variable.
Just fix the same error on my machine.
In my case, it is fixed by add the MATLAB path into the SYSTEM environment variables:
add in PATH
-C:\Program Files\MATLAB\R2011a\bin;
-C:\Program Files\MATLAB\R2011a\runtime\win64
Wish it is helpful.