java.library.path, classpath Netbeans 8.0.2 - java

I have just installed the Matlab Runtime on:
Distributor ID: Ubuntu
Description: Ubuntu 15.04
Release: 15.04
Codename: vivid
You can find the Matlab runtime here in my case in installed R2015b (9.0)* (MATLAB Runtime 9.0, for R2015b, is intended to work with MATLAB 8.6, which is also R2015b).
The Matlab libraries get installed to: /usr/local/MATLAB
I am using Netbeans 8.0.2
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
The error I get off my program is as follows:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the required library libmwmclmcrrt.so.9.0 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: 9.0.
On the install of Matlab it does say:
On the target computer, append the following to your LD_LIBRARY_PATH environment variable: /usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:
I have added this line to Project > Properties > VM Options:
-Djava.library.path="/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:"
And I have added the same folders to Project > Properties > Libraries using the: Add JAR/Folder button.
I have put the following line of code into my program:
System.out.println(System.getProperty("java.library.path"));
To which I get output correctly as:
/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64:
However, it continues to fail to run with the same error.
I installed IntelliJ IDEA Community edition and with no mods at all and the code just runs without any issues. I really wish to keep with Netbeans and would like to understand the issue. Any ideas?
IntelliJ has the following loaded:
/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java
-Didea.launcher.port=7532
-Didea.launcher.bin.path=/home/code/idea-IC-143.1821.5/bin
-Dfile.encoding=UTF-8
-classpath /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/cldrdata.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/dnsns.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/icedtea-sound.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/localedata.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/nashorn.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunec.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunjce_provider.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/sunpkcs11.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/ext/zipfs.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jce.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/jsse.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/management-agent.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/resources.jar
:/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/rt.jar
:/home/code/NetBeansProjects/CO2model/out/production/TestModelABC
:/home/code/NetBeansProjects/CO2model/TestModelABC/dist/lib/co2model.jar
:/home/code/NetBeansProjects/CO2model/TestModelABC/dist/lib/javabuilder.jar
:/home/code/NetBeansProjects/CO2model/for_redistribution_files_only/co2model.jar
:/home/code/idea-IC-143.1821.5/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain test.Startup
.
:
:/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64
:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64
:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64
:
:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni
:/lib/x86_64-linux-gnu
:/usr/lib/x86_64-linux-gnu
:/usr/lib/jni
:/lib
:/usr/lib

java.library.path is the path that java uses to find native libraries.. An error would be caused if
There is no file called libmwmclmcrrt.so in the path
The permissions of the file libmwmclmcrrt.so is not correct
So my advice would be to run a search with name libmwmclmcrrt.so to know whether the file is in the system or not..
If found you could manually copy-paste it to this path
/usr/local/MATLAB/MATLAB_Runtime/v90/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/bin/glnxa64:/usr/local/MATLAB/MATLAB_Runtime/v90/sys/os/glnxa64
If already present in that path maybe you could check the file permissions..
In most of the cases the error is caused because the library isn't found..

to set java.library.path in netbeans. Select project, right click on Properties. Select Run option, Change VM options to add native library -Djava.library.path="absolute\path\to\your\library\files".
after this, you need to load the library through `System.load("absolute\path\to\your\library\files");' in static block.
like this
static {
try {
System.load("absolute\path\to\your\library\files");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
also modify the LD_LIBRARY_PATH environment variable to include the path where the matlab library is located.
export LD_LIBRARY_PATH=/path/to/your/library:$LD_LIBRARY_PATH

I think we have a better explanation here.
In short:
Some system property is only read once when the JVM is started up, thus changing it after start-up will not make JVM load it again, so System.setProperty() will not work.
In particular, java.library.path is read-only.
So, the only way to set it, is to set %PATH% in Windows, or $LD_LIBRARY_PATH in Linux-like systems.
To set it system-wide in Linux, edit /etc/environment. If you want to set it only user-wide, check this very practical article.
LD_LIBRARY_PATH="/some/preset/path:/your/path/to/add"
Plus: in case that you don't know it, a locate libmwmclmcrrt.so.9.0 is always very helpful in this situation, specially when you may have various version of a file in different location with identical name. And /your/path/to/add is a directory.

Related

Unsupported Java Version: Cannot start under Java 1.7: Java 1.8 or later is required

I just updated to IntelliJ IDEA 16 which comes with Java JDK 1.8. Fyi, I had downloaded Java JDK 1.8 a long time ago.
I tried to run my plugin that I am developing, and I cannot even do that, I get the following error message (slightly condensed)
"C:\Program Files\Java\jdk1.7.0_45\bin\java" -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea "-Xbootclasspath/a:C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 144.3143.6\lib\boot.jar" -Didea.config.path=C:\Users\Christopher.IdeaIC14\system\plugins-sandbox\config - ... -Dfile.encoding=windows-1252 -classpath "C:\Program Files\Java\jdk1.7.0_45\lib\tools.jar; ... ;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 144.3143.6\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.intellij.idea.Main
Unsupported Java Version: Cannot start under Java 1.7.0_45-b18: Java 1.8 or later is required.
So, I clearly know what the problem is; however, I cannot seem to figure out where the location to fix this is.
I have tried a lot of things so far; most involve using the search box in Settings and switching whatever I could to version 1.8. Also, I had updated my Environment Variable for Java from 1.6 to 1.8
With all of these changes, nothing is working! So how do I go about fixing this seemingly simple issue?
Set IDEA_JDK (or IDEA_JDK_64) environment variable.
Check Selecting the JDK version the IDE will run under
TL;DR --> Set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_51
Java 8 is required to run IntelliJ IDEA starting from version 16 on all the supported platforms.
The actual JDK version used by the IDE can be verified in Help | About dialog (open any project to access the menu).
idea64.exe uses this JDK search in the following sequence:
IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable
Under Arch Linux you can simply set java 8 as default (you must have it installed):
$ sudo archlinux-java set java-8-openjdk
In case anyone arrives here and hasn't had any luck with the other solutions, try this. I'm using PhpStorm under OSX, but the steps are probably applicable to JetBrains' other IDEs too:
Navigate to your IDE's config folder (see this article to learn how to find this folder's location).
Open the idea.propeties file.
If a JVMVersion attribute exists, delete that entire entry. If it doesn't exist, then this probably won't be of much help!
Save the file.
Launch your IDE.
Just set JAVA_HOME system variable to your JDK 8:
Run in cmd
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_111"
don't foget to change to your java path
In my case, Ubuntu 14 (32-bit), I opened the file:
/home/<user>/Programs/PhpStorm/bin/phpstorm.sh
and after
if [ "$JDK" = "" ] && [ "$OS_TYPE" = "Linux" ] && ........... fi
I added:
if [ "$JDK" = "" ]; then
JDK="/usr/lib/jvm/java-8-oracle"
fi
And then it works!
Double check that your JAVA_HOME points to the correct 1.8 Installation and make sure that in the PATH env there is no reference to "C:\Program Files\Java\jdk1.7.0_45\bin".
Try to print your JAVA_HOME/PATH from the Console and see what the output is. If your changes are not reflected logout and then login again.
IntelliJ 16 REQUIRES Java 8 to run, it won't run under Java 7. It's compiled to Java 8 classes so it can't ever be run on an older JVM.
This is well and clearly mentioned in the documentation.
So if you have your system JVM be an older one, it will fail to start unless you coerce it into using a non-default JVM.
Possibly you have some java related executables left over in your Windows/System32 directory, where some older Java installers would drop them. Delete these by hand from the file system and see what happens.
Just in case this page needs one more recommendation, I fixed the problem in my case by going to the IDE's config folder (as #Nate puts it, see here for how to locate it), and deleting the idea.jdk file (which held a reference to a 1.6 VM).
Apart from setting the correct Java version for the global, per project and per module SDK, for the Java Compiler, and for the language level, you also must set the Target bytecode version both for the project and (if you use maven) for each maven module.
Often the project bytecode version is correct but the module bytecode version is lower, i.e. 1.5.
The per-module bytecode version is not displayed when opening the default preferences via File > Other Settings > Default Settings. You must edit the current preferences either via a shortcut (i.e. ⌘+,) or from the main menu as shown below (for mac):
I had the same problem. All paths pointing to java jdk 8, but still throwing the error. I was able to run Android Studio by running the "studio64.exe" instead "studio.exe" in the bin folder

Updating the PATH Environment Variable stops Eclipse working

To set up the JDK, I have added the following to the PATH environment variable in Windows.
C:\app\A_McLeod\product\11.2.0\client_1\jdk\bin
The problem is that Eclipse no longer opens and I get the error;
Failed to load the JNI shared library
"C:\app\A_McLeod\product\11.2.0\client_1\jdk\bin..\jre\bin\server\jvm.dll".
How can i get both Eclipse and the JDK working simultaneously?
Ensure that your version of Eclipse and JDK match, either both 64-bit or both 32-bit (you can't mix-and-match 32-bit with 64-bit). See here
You can edit eclipse.ini and set the -vm to the java executable you want to use

Eclipse/Java class couldnt be found

I am new to Java and have some basic problem. Would appreciate your help guys.
I try to run a HelloWorld program but having an error:
"Error: Could not find or load main class HelloWorld".
I noticed that Eclipse saves the project in parallel virtual store directory and not the one I mentioned.
When I manually move the project to Eclipse_Workspace directory it works just fine. What should I do for Eclipse to save the files correctly?!
If needed:
I downloaded JDK 1.8.0_51 for Win 32 and Eclipse IDE for Java developers (Luna Service Release 1 (4.4.1)). Win7 32 Ultimate.
I added a Path value in System Variables -
C:\Program Files\Java\jdk1.8.0_51\bin
Default Resource Path in Eclipse is:
C:\Program Files\Java\Eclipse_Workspace
Thanks
VladBio,
Make sure the following environment variables set correctly:
JAVA_HOME = jdk root folder (C:\Program Files\Java\jdk1.8.0_51)
Path = jdk bin folder (C:\Program Files\Java\jdk1.8.0_51\bin)
To test this go into your cmd (Start -> run -> cmd) and type:
java -version
C:>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
If you see the correct version then the issue is in Eclipse.
In Eclipse you can check your JDK settings in Windows -> Preferences -> Installed JREs. Your correct JDK should be listed there.
On Eclipse you can also have project specific java version.
Right click on your project -> properties. On Library tab you should see something like JRE System Library [jdk1.8.0_45]
Check here for a more detailed answer of what could be going wrong.
I Hope this helps.
Thanks a lot.
I suppose I figured this out.
It was a problem in eclipse - it couldnt automatically make a changes in java directory because any change there is allowed only with admin approval.
I changed the path in eclipse to a folder on my desktop. It solved out the problem.
BTW I tried what you said and the output in cmd was identical to yours.
Thanks again

Failed to run JAVA even though path is set on Windows 8 Enterprise - Cordova

I have made a new Ionic / Cordova project and I'm trying to build it on windows 8.1. I installed JDK and JRE 7 as well as android sdk and ant and added them to my path using the following instructions.
cordova platform add android not working while listing Android targets
When I execute ionic platform add android or cordova I am still getting the following error:
C:\Users\BogdanR\.cordova\lib\android\cordova\3.4.0\bin\node_modules\q\q.js:126
throw e;
^
Error: Failed to run 'java -version', make sure your java environment is set up
including JDK and JRE.
Your JAVA_HOME variable is C:\Program Files\Java\jdk1.7.0_51
Error: Command failed: 'java' is not recognized as an internal or external command,
operable program or batch file.
at C:\Users\BogdanR\.cordova\lib\android\cordova\3.4.0\bin\lib\check_reqs.js:62:22
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Socket.<anonymous> (child_process.js:956:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\nodist\bin\node_modules\cordova\src\superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
Unable to add platform android. Please see console for more info.
I tried modifying both system variables and user PATH variables.
THE WEIRD THING is that I can type in java -version and it works:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
I am using nodist to manage npm if that is of any relevance.
After I ran into the same issue, the following steps seems to have fixed it:
PATH needs to contain the bin folder of the Java installation path C:\Program Files\Java\jdk1.8.0_05\bin make sure the bin is included
JAVA_HOME needs to be set to the root of that Java installation folder, in my case C:\Program Files\Java\jdk1.8.0_05
In my case, i had multiple java instalations, and whenever i tried to print "echo %java_home%" command on command prompt, it always used to return "%java_home%" as it is.
So i uninstalled all the java versions and then installed it again, and whoola, it worked.
Hope this helps someone.
There is one thing you can try is to set this variable JAVA_HOME to C:\Program Files\Java\jdk1.7.0_51\bin
Since you are using Windows, you can go to Control Panel to update it.
You were able to run java -version probably because it's included in the User's path.
In my case, It said "JAVA_HOME variable is unvalid, C:\Program Files\Java\jdk1.7.0_51".
Then I added a quotation mark to JAVA_HOME. Just like "C:\Program Files\Java\jdk1.7.0_51". Finally It works. May This can be helpful
There was a bad entry in the path that corrupted my whole system path.
C:\Program Files\Microsoft SQL Server\110\Tools\Binn";C:\Program Files\Microsoft\Web Platform Installer\;
Seems like that quotation mark is an entry added by SQL Server installation or web platform. I never added those to the path so it might be the installers fault?

Running J2EE Eclipse in a VM - Unable to find a javac compiler

Kinda new posting up questions here so bear with me. I had to install a XP VM recently in order to run a program that required use of an Oracle 10g client. I setup my tomcat server and when I went through the directory and started the .jsp file, I got this error
2011-02-22 09:13:01,291 ERROR (org.apache.jasper.compiler.Compiler:394) - Javac exception
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
Weird thing is I set my JAVA_HOME variable in my VM to 'C:\Program Files\Java\jdk1.6.0_24;' and my PATH variable to '%JAVA_HOME%\bin;'.
It says that its a jasper-complier error... I made sure to add several TOMCAT_HOME variables in my eclipse library path that looked at the jasper-compiler,jasper-runtime,jsp-api.jar, and servlet-api.jar located in my tomcat server folder.
I also followed these instructions here, that state to add the jdk\bin's tools.jar to Eclipse's Ant runtime global entries
Any help appreciated, I'm stumped.
It usually happens because Oracle ships with an outdated version of JDK which conflicts the PATH that we set. Scan your PATH environment variable for any oracle JDK and remove it. It should help.
Look into your Launcher configurations (of type 'Apache Tomcat') and find the one created when you launched the JSP. There must be an 'environment tab'. You could define the JAVA_HOME here. Is this a version 5 of Tomcat (or earlier) ? Starting with version 5.5, Jasper has an embedded JDT (eclipse java compiler).
Hey I figured it out, just made sure you add to your JDK to your PATH variable (ie. java\jdk...\bin) and I also added it to my tomcat\lib folder and added it to my projects library as another variable.

Categories

Resources