New to java 1.8.0_73 - Javac command not recognized - java

When I try to compile a .java file, it says "Command javac not found."
I've done a fresh install of Java using an installer downloaded from their website. I've tried the solution on all of the other posts that says to check my path, but it already includes "C:\Program Files (x86)\Java\jre1.8.0_73\bin;" which contains which looks like a ton of utilities - except, there's no javac executable.
I searched my C drive with File Explorer, and couldn't find it anywhere. I've installed and reinstalled, so I think I might just be looking for the wrong thing to compile my programs. Please help!

You have installed the java jre. You need to install the jdk.
The jre (java runtime environment) contains the files needed to run java.
The jdk (java development kit) includes the jre and also all the development utilities.
Go to the download page, and select the jdk.

I had the same problem and with jdk-8u73-windows-i586.exe from the Oracle downloads page - it installed a JRE and no JDK. Solved the issue by downloading jdk-8u74-windows-x64.exe, which installed both a JRE and a JDK.

Related

The specified JDK folder doesnot contain JDK (NetBean IDE Installer)

This appears in netbeans IDE Installer,
what should I do here?
I had that issue when my JDK version was too far ahead of NetBeans. JDK 11 was a problem.
When I installed JDK 8.x, the NetBeans installation worked.
Also, note that the NetBeans installer requires the JRE in addition to the JDK, but doesn't mention this at first. (Again, I used JRE 8.x).
This error means, that you put invaild JDK directory. Maybe it happens becouse you are addin "\lib" at the end - try without this.
You need to find place, where JDK is installed. Try to use "where javac" or this code below:
C:> for %i in (javac.exe) do #echo. %~$PATH:i
Write this into cmd.exe, and then copy and paste this address in NetBeans (JDK for the Netbeans IDE).

How can I able to compile and run java programs without JDK with just JRE?

I have installed JRE in my machine and downloaded Eclipse IDE and started to work on that IDE.
I have read from some blogs like Without JDK we can't compile the java program but i can able to run program/application in eclipse IDE.
Then in some other blogs gave me information like eclipse will have own JDK so try to run in command prompt to get know information. When i try to compile the program in bin folder(C:\Program Files\Java\jre7\bin) via command prompt it says javac couldn't recognize. I thought it's because of compiled class file is missing as JDK is not installed so i have copied the project from Eclipse IDE with class file and try to run the program it says couldn't find or load main class filename.java.
Even i have set environment variable as Java_home for the JRE bin path.
Pls explain JDK and JRE difference in brief to me.
I understood the concept now.
Application is running in eclipse even without JDK installation as eclipse has its own compiler and JRE installed in my machine.
Copy of project from Eclipse IDE with class file is throwing error like 'couldn't find or load main class filename.java' because runtime environment couldn't find the class file as Javac compiler and Eclipse compiler class will be different so content will be different. So java interpreter couldn't find the class file of eclipse compiler class file(As similar to serialization concept).
Not possible to compile your java code in absence of JDK. javac , the java compiler, and other Java Development related binaries are available in the JDK only not in JRE.
For Getting Differences between JRE and JDK , you can refer here.
The JDK, or Java Development Kit, allows commands such as `java` and `javac`. The JDK is required to develop and run Java applets and applications.
The JRE is used to run Java programs. It is required to run any Java programs.
This might help: https://stackoverflow.com/a/29160633/6423975

JDK for Eclipse(in windows platform)

My qustion is really simple, all in the title.
After some tests I found that by given a JRE/bin directory in the path(environment variable) , Eclipse can run normally with no problem. And Eclipse will never try to find the JRE by using JAVA_HOME variable.
And in eclipse, I know that I can add installed JREs in the window preference and choose a JDK folder instead of a JRE folder. And for each project, we can change the compiler level.
Since Eclipse can also compile the codes, when is JDK used? Debug? or what?
Eclipse uses its own compiler to compile Java code. It is different than the javac compiler that comes with a JDK. In fact, you don't need a JDK to compile and run normal Java projects in Eclipse. A JRE is obviously needed to reference the required Java libraries.
However if you are using Maven or some other tools that sometimes depend on a JDK component, then you need to install a JDK on your machine. For example, Maven has an option to rely on the tools.jar that comes shipped with a JDK.
Eclipse uses the JRE you specified as default or per project settings. This could be a (only) JRE installation or a JRE from a JDK installation.
I think the more interesting question is: When should I use a JDK instead of an JRE?
The JDK includes tool that are not included in the standalone JRE. E.g. the javadoc.exe for exporting the documentation from javadoc annotated comments in the code. This Program is not included in a standalone JRE. so if you want to export your javadoc documentation you need to add an installed JRE based on a JDK installation first, so Eclipse is able to use the javadoc tool.
It could be a little hard to give a thorough answer to this but I know that at least for using Maven/m2e Eclipse needs to be run in a JDK.
First of all eclipse is a java code it wouldn't run without java installed to prove it (on your personal expence) copy the eclipse folder elsewhere and uninstal the JDK and try to run jave it wouldn't it would output the error message no JDK but instal JDK and run eclipse from the copied location it would run as a first time asking you about the workplace directory!.

unable to find javac compiler from an executable jar

I am working on a simple java editor that uses ant to call JDK.
On eclipse everything work fine, I am able to build build.xml. The problems is when I export my Editor to an executable jar, and I try to build the build.xml of a project, I get the famous problems:
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"
Important:
If i run my jar Editor from cmd it's work fine ,but if i double click the Editor jar it doesn't work , i get the famous problem (unable to find javac compiler...).
Notice:
JAVA_HOME points to the JDK.
I am using ant.jar and ant-launcher.jar.
Eclipse points to my JDK installation.
tools.jar is added to JDK/lib folder
the solution is to set fork attribute to yes on javac target .
Perhaps JAVA_HOME does not point to the JDK.
JAVA_HOME is currently set to C:\Program Files (x86)\Java\ jre7
The message is fairly informative and to the point, is it not?
Your JAVA_HOME looks like it is pointing to a JRE installation, not a JDK installation. (The error message says it is "C:\Program Files (x86)\Java\jre7"!)
A JRE does not include any of the Java development tools ... such as the javac Java compiler that Ant is trying to load / use.
If you really have a JDK installation on your machine, then all you need to do is to change the JAVA_HOME environment variable so that it refers to it ... instead of the JRE. Otherwise, you also need to download and install the relevant JRE.

Eclipse & web development

I'm trying to learn servlets and JSP and would like to do this with Eclipse. When I click about in my current version, I get this info:
Eclipse IDE for Java Developers
Version: Helios Service Release 2
After searching a bit, it seems you cannot access these features with this version - you need "Eclipse IDE for Java EE Developers".
I've found a tutorial to install these plugings in your Eclipse installation, but I'm just getting a "failed"-message with no error message. After this, I decided to just download a new version (the EE one ofcourse) from the Eclipse website. The old installation is in c:\program files (x86)\eclipse, the new one in c:\program files (x86)\eclipse2.
The old one still works fine, but when I try to run the new one, I get this:
I have no clue what is wrong here. Am I doing something wrong? The only thing I want is to use Eclipse for JSP and Servlet Development (soon also EJB).
Thanks
Eclipse cannot find your JRE/JDK. Put the JRE/JDK folder in your PATH variable. My JDK is located here:
C:\Program Files\Java\jdk1.6.0_24
Should be a similar path for you. Add that to your PATH variable.
Have look at this tutorial to find out how.
Make sure a Java 6 JDK is installed. If it is then you should be able to type javac -v on a command prompt and see output like this 'javac 1.6.0_26'
Once you have this correctly eclipse should start with no issues.

Categories