I implemented a SDK in C++ (API exported in C). This SDK compiles into a DLL for Windows and a .so for Linux. I also implemented a Java wrapper using JNA. This wrapper ships with .so and DLL inside it and I check at runtime which operation system is running and extract it on a folder specified by developer. It works well.
The problem is that one of customers that use Linux (I have just a couple of them on Linux) said that the library was not loading with a undefined symbol error. Here is the error:
java.lang.UnsatisfiedLinkError: /usr/lib/libBXSDK.so: /usr/lib/libBXSDK.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE
Initially I thought this could be related to some standard .so not being present. I then sent him a a very basic C++ executable and asked him to run. It worked. I then sent him a very basic Java application that DOES NOT use the SDK, but only calls System.loadLibrary("BXSDK"). After copying libBXSDK.so to /usr/lib, he ran the basic Java application and the error was the same.
I then decided to check his Java version, and realized he was using Oracle JDK latest version, and I saw that on my test environment that runs CentOS 7 (customer runs RHEL 7) I use OpenJDK. Immediately I installed Oracle JDK on my test environment and I saw the same problem.
So, my question is. What is the difference between Oracle JRE and OpenJDK (JRE), that causes this issue? Am I doing something wrong on my .so that OpenJDK is able to handle but Oracle JRE is not?
Thanks
Did you verify if the folder is the case as mentioned in this post: http://ubuntuforums.org/showthread.php?t=1323888
Fellow (dontexist) member's comment is quite valid in general, the fact that OpenJDK being able to make the calls makes me think if library load itself was unsuccessful.
I figured, this may not entail an answer to the question - "What is the difference between Oracle and Open JDK in loading semantics". Not sure if I can retract this post being an answer, but let others take the opportunity to explain about it.
Related
I know this is often a common issue but the Java 8 aspect confuses me. I'm aware that since Oracle removed JavaFX from the Java distribution, this issue is usually resolved with VM arguments (--module-path,--add-modules, etc).
However, I'm exporting a .jar file using jre 1.8.0_202 in eclipse. And this works great without any arguments on my windows machine. Sadly when I move this jar to my linux machine, I see the classic "Cloud not find or load main class". For reference, the linux machine is running 1.8.0_342. I would think that this shouldn't be an issue because I'm using older Java versions?
Any insight on why this works on one platform and not the other?
I am getting an error when trying to run a .java file as a Java Application and I get the following error:
Unbound classpath container: 'JRE System Library [JavaSE-14]' in project <project_name>
I tried to change the execution environment and for JavaSE12 and later versions there are no compatible JREs. (But for JavaSE11 the compatible JRE is java-11-openjdk-amd64)
I do not know what to do because the project I am working on doesn't work with old Java versions. How can I choose an environment for the latest Java versions?
Note: I am using Ubuntu 20.04 if that makes any difference.
tl;dr
I am not a Linux user, so I may not know best. But I suspect the simplest approach to running your .java file is to:
Obtain and install a JDK for Java 15 for Linux
Call java app on the command-line, passing the path to your .java file.
Backwards-compatibility is a priority for the Java team. Most any existing Java app should be able to run with the latest version of Java. There are exceptions, but they are very few.
JRE is passé
The JRE (Java Runtime Environment) was a subset of the JDK (Java Development Kit), omitting some of the programmer tools. The JRE as a separate product seems to be getting phased out.
Oracle and much of the Java community has shifted away from the idea of regular users having Java installed on their personal computers. Instead, apps should be delivered with a JVM specific to their host platform bundled within the app. This bundling of a JVM can be done using newer tools such as jlink and jpackage.
For more info, read:
Java Client Roadmap Update - Oracle (2020-05)
Java is still Free
Obtain a JDK
You said you have a .java file to execute. That file must first be compiled before it can be executed. The more recent versions of the java app can do both steps at the same time, compile & execute.
First download and install a JVM for your host platform.
Java 11 is the current long-term support (LTS) version. Java 15 is the latest release. You may want to read about the six-month release cadence for Java.
You have a bounty of vendor choices providing implementations of Java. Here is a graphic flowchart I made to assist in choosing a vendor.
If the steps shown here are overwhelming, I suggest either:
Using apt-get or similar package installer to obtain a build of OpenJDK for Ubuntu. I am not a Linux-user, so I do not know the details.
Head over to AdoptOpenJDK to download an installer for Linux.
Some motivations to consider in selecting a vendor.
Compile & run your app
Once your JDK is installed, on a console (such as Terminal.app in macOS), run something like the following. The java command should both compile and execute your .java file, if that single file makes up your entire app.
java /path/to/some/folder/MyJavaApp.java
Target Environment
Windows 7 (6.1)
Java 1.8.0_121 64bit
I recently created a minimal java environment consisting of just the single file java.exe in a newly created, empty directory and successfully ran a simple HelloWorld.class file simply by copying it to the same directory and typing:
.\java HelloWorld
I found this kind of surprising, and wondered if maybe because the version of java I was using (jre 1.8.0_72) had been installed from an .exe file whether there was something in the Windows registry telling java.exe where to find rt.jar and such.
Running the java control panel, you can certainly see java 1.8.0_72 is in there:
I if I used a java version which was NOT installed (i.e. a standalone java version) would I get a different result?
Well, before trying a stand-alone version I think I'll try a computer having NO java on it at all. Same exact set up as before.
Found part of the answer on my wife's Windows 10 computer (which has no java on it):
Clearly, I should copy java.dll somewhere. Think I'll put it in the same directory as everything else (i.e. the same one as the java.exe), and try that.
Nope. Same as before.
So clearly java is looking in the registry to find its .dll.
I've downloaded jre-8u121-windows-x64.tar.gz. I'm going to try the same experiment with that.
Tried the same experiment with java from the tarball above. Exact same symptom. Cannot find java.dll.
Having done a little reading, I see that Embedded Java SE has a way to create custom deployments of java. There appears to be no official analogous mechanism for Java SE for Windows.
Doing a little more reading, I see that there is a mechanism called the Invocation API which can be used to run java, bypassing java.exe. This might be something to try. Might also be time to start surfing the HOTSPOT code.
More on the Invocation API here: http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html
An intriguing note I also ran into during my reading said this:
Private vs. public JRE - Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK.
I read this here: http://www.oracle.com/technetwork/java/javase/install-windows-142126.html
You might try this experiment with THAT jre.
Today I also face same problem .and I found the solution for this go-to your JDK bin copy path from there and peast this path to environment variable path and the priority should be first that mean it should be peast in starting of all path.
I messed with the version of Java that I was using in Matlab and then I had some issues, so I tried to delete Matlab and all versions of Java from my machine then reinstall Matlab. According to,
http://www.mathworks.com/matlabcentral/answers/130359-how-do-i-change-the-java-virtual-machine-jvm-that-matlab-is-using-on-windows
Matlab already has java in it, so I assumed that the fresh install of Matlab would fix the issue. But it did not and I ended up having to install Java and point to it as per the article above just to get Matlab working with Java again.
The issues are these:
When I start up Matlab, I get
Sometimes it spools red errors and I have to shut Matlab off
I loose a lot of the interactive features, for instance; I cannot click on the folder ribbon to move through the folders as:
3.b also, sometimes I cannot resize windows.
So, I lost some functionality. How can I run the version of Java that ships with the student version of Matlab?
Thanks!!
I point the system MATLAB_JAVA variable to:
C:\Program Files\MATLAB\R2015a\sys\java\jre\win64\jre
Which is the original java version that MATLAB was shipped with. For some reason, the new java is buggy with the new matlab
everybody .I have been working on this issue for hours .The problem is that I cant debug my Database class.Once the break point hit this line
final Database db=new Database(this);
I am trying to step into my Database class But eclips says “Source not found” and shows a buton named “Changed attach source” .So I have searched an explanaition on internet .I have found one here
to be able to fix this error.I have to find the where JDK is but I couldnt under this location.Just JRE folder is available There is no JDK
C:\Program Files\Java
If you don't have JDK you should probably install it. Find it here
JDK/Java SDK = Java Development Kit/Java Software Development Kit - what you need to write programs that require Java or use libraries written in Java. For example, if you were to write your own word-processing tool in Java.
JRE = Java Runtime Environment - what you need to run programs/software that require Java or use libraries written in Java. For example, OpenOffice requires the Java Runtime Environment
JRE allows you to run Java, whereas JDK allows you to program with it.
You need to install JDK from here http://www.oracle.com/technetwork/java/javase/downloads/index.html. what you are having is JRE, but you dont have jdk. remove existing JRE and install JDK from the site.
What is the Fully qualified name for Database class ?
You need to install JDK from
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Then from JDK folder u will find file called src.zip which is include all the source code of the standard class's . But i believe
this will not show the source for this Database class since its not standard class if you can get the fully qualified name of the class you can find its jar from
http://www.findjar.com