Confused about how to debug my class - java

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

Related

protege 3.5 set java path windows

when trying to run/reinstall protege 3.5 it fails because it uses the wrong java path: it's trying to run c:\ProgramData\Oracle\Java\javapath\bin\java.exe, in reality the correct javapath is c:\ProgramData\Oracle\Java\javapath\java.exe but I don't know where protege gets this from? I'm using the web installer (launchanywhere).
I've looked at the environment variables and there's nothing that mentions javapath\bin... however ...\java\javapath; is part of the path variable, how can I change protege and its installer to acknowledge this java path?
thanks
I tried using install_protege_3.5.exe LAX_VM "C:\ProgramData\Oracle\Java\javapath\bin\java.exe" as suggested here: http://rivix.com/Tech_Tips/tech_tip_win3.php for other launchanywhere package.
but the installer seem to ignore my parameters, I then proceeded to download the full version including the vm, I previously had downloaded only protege.
With the full version (e.g. including the vm) I was able to launch the installer to choose my preferred vm. It's all working now, thanks

Configuring SDK in IntelliJ

I have a problem getting my SDK to intelliJ idea, i have downloaded Java SE newest edition, and put it in a seperate folder on my desktop. Whenever i chose it from intellij it just shows an error, Anybody knows a fix?
Check if you have there really the JDK home. If you click to the arrow on the left of your Java SE, it should look something like this (my jdk1.8.0_152 is the proper home folder of a JDK):
Also your Java SE\bin folder should contain the javac.exe file - notice the c at the end of the file name :)
I always download the full installer from Oracle (just search google for oracle java SE JDK download) and then run it. You may specify the destination folder where you want it to be installed, or you rather leave the default (I strongly recommend that).

Does java use the registry to locate its default jar files?

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.

System.loadLibrary works on OpenJDK but not on Oracle

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.

Selecting the correct Java, JRE and JDK versions when building an executable JAR for distribution?

I am putting together my first Java package for distribution to users, and am running into some difficulties. I have jar packages that I've built that users can't run; the error messages vary, but are all "version" something or another. I suspect I'm selecting the wrong build paths, and I'm not quite sure where to start troubleshooting because I don't clearly understand the differences between the Java executable (javaw.exe), the JDK and the JRE; I have some questions that I'd like answered which will help in that understanding. I'm used to the way that C# executables compile in VS; wrapping my head around how executable jar files come together is still a little mysterious to me.
Although I've done a few google searches, most of what I'm finding is how to build a jar file, but not how to manipulate/use/select the Java, JRE and JDK versions appropriately to ensure compatibility. I do understand that the JRE includes the virtual machine that allows Java bytecode to run anywhere, and that the JDK includes development tools...but as to figuring out which version I AM running, vs which version is used when building jar files and which version SHOULD be used...I am completely lost.
I'm using Eclipse Indigo under 64-bit Win7. My build path includes the following:
JRE System Library: C:\Program Files\java\jre7\*
External paths: C:\<MyDocuments>\java\lib\commons-io-2.4*
I also have, installed on my machine, the following paths which are NOT included in the build:
C:\Program Files (x86)\java\jre7\
C:\Program Files (x86)\java\jre1.5.0_22\
C:\Program Files (x86)\java\jdk1.7.0_21\
The users that will be running this executable file are only supported (by corporate IT) up to JRE5. I suspect that my building this pointing it jre7 is one of the things that's messing with me.
My first stupid question is whether there's a difference between "Java" and the "JRE" when it comes to version numbers. For instance, when I read about JavaSE7 or JavaEE7, are they talking about the JRE version for the standard or enterprise editions? Are the development kits and runtime environments just components to JavaSE/EE? Or are they separate and distinct products?
Then, my understanding is that I should build this jar using the lowest-common-denominator JRE expected from my users. In this particular case, because the corporate standard is JRE5, I should build this pointing to JRE5 instead of JRE7. Is that a correct assumption?
Does it matter if I build using the 64bit or 32bit version? Some older machines may still be 32bit running JRE5, so I need to make sure I'm backwards compatible.
The Program Files (x86) naming conventions confuse me. JRE7 installed as \jre7. However, JRE5 installed as \jre1.5.0_22, and I also have jdk1.7.0_21, which, based on the JRE name, I assume to be the Java7 Development Kit. Do I need to install the Java5 Development Kit to properly build this program? And am I properly interpreting the versions from the filenames? that 1.5 represents Java5 and 1.7 represents Java7?
Then, my last question I know there's an Eclipse option to copy the external libraries to the project. I assume that if I do this, this will be included with the jar so the users do NOT need to have the Apache Commons jars on their local machines in order for this to run properly. Does the manifest include any confirmations that these files were included? I've been unable to find any references...so I'm trying to verify if I'm even pulling the Commons libraries over and where to look to get that confirmation.
This is just speculation, but I think you may have to re-write the program with the java5 jdk, because some of the APIs/libraries used in java7's jdk may not be recognized by the java5 jre. (Just like it wouldn't be possible to play PS4 games on a PS2... without any serious modding)
If you write the program in Eclipse, you can just select what library you want to use as you create the Java project. At the "Create a Java Project" screen, you can select the "Use an execution environment JRE:" or "Use a project specific JRE" or "Use default JRE" option. (I have jdk6 and jdk7 installed on my computer so I'm able to select those two options; which is why you may have install the jdk5 in order to create a java 5 project.)
You are properly interpreting the filenames. jre1.5.0_22 is java 5 update 22.
There is a way to specify which JRE is used to run the jar file.
cmd prompt >
"C:\Program Files (x86)\java\jre1.5.0_22\bin\javaw.exe" -jar "filepath_filename.jar"
Drop the "w" from the javaw.exe, and you'll be able to see any console and/or stack trace output.

Categories