Does java use the registry to locate its default jar files? - 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.

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

Confused about how to debug my class

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

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.

Google didnt help - A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse [duplicate]

This question already has answers here:
Eclipse - no Java (JRE) / (JDK) ... no virtual machine
(35 answers)
Closed 8 years ago.
Looks like a common issue, but facing issues inspite of searching around.
My environment: Win7 64.
Downloaded: Java from here and Eclipse from Here
After installing Java & extracting eclipse, I try to run Eclipse from unzipped folder and get the error. .
My background: C# .net / C++ - windows development. I would prefer to use C#. But not that adventurous to try going mono on android (unless recommended - unlikely).
So trying to go Eclipse & Java the recommended way, although i have zero Java experience, so far.
Here is what I have tried.
Created env variables as per this thread. Didnt help.
Java Install folder was - 'C:\glassfish3\jdk'
Tried referencing both environment path with both these locations - 'C:\glassfish3\jdk\bin' and 'C:\glassfish3\jdk\jre\bin'. (I presume i should reference the latter - jre being the runtime environment?)
Modifying eclipse.ini - from this link
(I dont think i am doing this right. I am not sure how to go about this. How to modify this file. Didnt try experiment much. Also, Do i need to remove the environment variables from previous step before attempting this?)
Could there be problem with the java i installed? There was some configuration items which popped up while installation. I just continued without configuring. (I thought it wes the additional items which i didnt need - glassfish)
First, you shouldn't have installed Java 6. It is EOL'ed. Install Java 7 instead. And I recommend that you install a JDK not a JRE because that will give you the option of running Java development commands outside of Eclipse.
Next, when you install Java, it will ask you where you want to install it:
Make a note of that directory location.
When the Java install has completed, look in the "bin" subdirectory, and you should see the javaw.exe file.
Check the system %PATH% environment variable, and if necessary change it to add the Java installation's "bin" subdirectory.
(Note that this is basically what the Java release's installation instructions tell you to do ...)
If you don't want to do a reinstall, then use Windows search to find the javaw.exe file from your existing install, and add its parent directory to %PATH%.
Try searching for the javaw.exe and add the location to your PATH.

How can I compile Java code in Windows without installing the whole JDK?

Let’s say the runtime environment (version 1.6.0_01-b06) is already in place, but since I lack administrative privileges in this particular PC, the JDK can’t be installed. So, is there any portable JDK or standalone Java compiler for Windows that doesn’t require installation?
You might try taking the tools.jar file from the JDK (you would have to copy it over from another machine) and see if that worked.
javac is essentially a small exe that starts the VM with the specific class for the compiler.
Also, there is nothing (that I am aware of) about the JDK install that you couldn't do with a copy of it from another machine. So get on a machine you can install the JDK on, install it, and then copy the files to a place on the machine that you lack the rights to and it should work.
You don't need to install JDK. Just copy it over from another machine, and set PATH to %jdk%/bin and JAVA_HOME to %jdk% (actually, only PATH is often enough). I do it all the time.
Eclipse works very well. being a portable ide, it will use it's own jdk. I personally use jGrasp w/ the jdk's folder as a PATH when I'm trying to write something quick.
You can try Jikes.

Categories