I feel really bad I need to ask here but I've struggled with this issue since morning :)
All I need is to set java 6 jdk to path. I set this to path in system environmental props:
C:\Program Files\Java\jdk1.6.0_45\bin;C:\java\maven\apache-maven-3.2.5\bin
and this to JAVA_HOME:
C:\Program Files\Java\jdk1.6.0_45
However, java -version still prints out: java version "1.8.0_25".
Thank you for any answer and have a nice rest of day :)
Windows 8
Drag the Mouse pointer to the Right bottom corner of the screen
Click on the Search icon and type: Control Panel
Click on -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
Reopen Command prompt window, and run your java code.
refer here
Related
So I installed JDK on windows 10, and followed a tutorial to make sure I did everything correctly (because I am a beginner). However, when I tried running a program to test it (HelloWorld), after compiling, I got this message:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe.
So, after some googling, I came upon the solution that I needed to remove that directory from my Path, on Environment Variables.
This did not solve anything, the message still showed up, and now:
'javac' is not recognized as an internal or external command,
operable program or batch file.
Only after did I realise I can't undo that path change, and am now at a complete loss.
What am I supposed to do?
To place the environment variable for Java JDK within the Windows 10 System Environment follow these steps:
1) Locate your JAVA home folder (directory). By Default I believe this is placed in the "C:\Program Files\Java" but this can be changed during installation so you will need to remember where it was installed if you've decided to stray from default. I believe the installer for the JDK should have also set an environment variable for you;
2) Open the Windows File Explorer application (not Internet Explorer);
3) In the far left pane of File Explorer locate and right-click your mouse pointer on This PC then select Properties from the displayed popup menu. A System window is opened and displayed;
4) From the System window select (left-click) the link item titled: Advanced system settings located on the left side of the window. A System Properties dialog window is opened and displayed;
5) Select the Environment Variables... button located on the bottom right corner of the System Properties dialog window. The Environment Variables dialog window is opened and displayed. There are two list sections in this dialog with the top section titled User variables for YourLoginName and the bottom section titled System variables.
6) Within the top section (User variables for YourLoginName) of the Environment variables dialog window you should see a variable titled JAVA_HOME.
If you do then select it, then select the related Edit button, a Input Box is opened and you should see the path to your particular JDK located within the Variable Value field (perhaps: C:\Program Files\Java\jdk1.8.0_60). If this field is blank then enter or paste the path to your particular JDK into the field and select the OK button.
If you do not see the JAVA_HOME variable within the top section (User variables for YourLoginName) of the Environment variables dialog window then select the New button related to the User variables for YourLoginName section and within the displayed Input Box enter JAVA_HOME into the Variable Name field and then enter or paste the path to your particular JDK within the Variable Value field (you can also browse to you JDK folder). Select the OK button within the Input Box when your entries are done.
7) Now look in the bottom section of the Environment Variables dialog window (System variables). You should see a variable named Path or PATH within the list (scroll down if you have to).
If you see the variable named PATH then select it then select the Edit button related to the System variables section, a Edit environment variable dialog window is opened and displayed. You should be able to see the path: C:\ProgramData\Oracle\Java\javapath located within the list (scroll if need to). If you don't then select the New button and enter: C:\ProgramData\Oracle\Java\javapath then hit your keyboard ENTER Key. Now, with your newly entered path highlighted, select the Move Up button until your path is located at the top of the list. Select the OK button when done.
If you DO NOT see the variable named PATH (and to be honest...YOU SHOULD) then select it then select the New button related to the System variables section, a New System Variable Input Box is opened and displayed. In the Variable name field enter: PATH and in the Variable value field enter: C:\ProgramData\Oracle\Java\javapath. Select the OK button when done.
8) Select the OK Button located at the bottom of the Environment Variables dialog window.
9) Select the OK button located at the bottom of the System Properties dialog window.
10) Close the System window.
11) Restart your computer.
If all worked well you should be good to go.
I have had installed Oracle and I was not aware that there was a JRE module inside. And besides, it had already automatically added a path for java here:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Additionally, I've had JDK 13.0.2
C:\Program Files\Java\jdk-13.0.2\bin
in here. it was like this before
and when I tried to compare java -version and javac -version, the respective results were this:
java -version >> 13.0.2
javac -version >> 1.08.282
Then reading this:
https://stackoverflow.com/a/40077770/14548725
I went to the path via directories (in windows 10 search bar write environments, click and open it. Goto system variables>Path> you will see the list of apps.)
I realized that the apps have a hierarchy and "java" command tool selects the first one it sees from the list.
So that I changed the order and did it like this:
current app order
Then I restarted windows powershell. and
java -version >> 13.0.2
javac -version >> 13.0.2
results has become same and consistent, luckyly.
and I examined my java file on desktop. And done!
you should set up the java environment correctly.
First add JAVA_HOME the base path of your jdk to your system.
then add %JAVA_HOME%\bin
I hope this gona be helpful for you.
I'm trying to get the java command to work on my computer. Whenever I try to use it, I get the error "'java' is not recognized as an internal or..."
What I've done
So far I've traced the issue through my system environment variables, which has a variable PATH that links to "C:\ProgramData\Oracle\Java\javapath" or javapath for short.
There are 3 files in the javapath folder, and if you click on them a popup says:
But when I examine the properties of the shortcut and click "open folder location" it sends me to the right place (?? what is this).
Just in case, I tried to recreate the shortcut; I called it java2 and it now works (opens a command box for a split second and closes) when I click on it. However, testing it in command prompt with the line "java2 -version" returns "'java2' is not recognized as an internal or external..."
Details
I just installed java 8, and I've verified that it was installed correctly
I'm running a 64 bit windows 7 OS
Have you checked your environment variables for Windows? When you installed the JDK/JRE the directory should have been added to the PATH variable. The directory added needs to contain the java.exe executable. It should be located in C:\Program Files\Java or something like that if you installed it using the default settings. Once you find that directory find the bin directory inside it.
In order to check that:
Right click My Computer and hit Properties
On the left side hit Advanced System Settings
Hit the Advanced tab and then Environment Variables down at the bottom
Find the PATH variable and then hit edit. Confirm that the location of the JDK /bin directory is there, if it is not then add it.
Also, if the JAVA_HOME variable isn't already set, this may be a good idea.
When I go to open eclipse, it gives me a run time error saying that the path to the JDK is not right.
I have no idea where to save the link so that i can get it to open
First Install Java on your pc: It should create Java Folder in C:\Program Files.
You have to set Classpath like this :
Set the CLASSPATH environment variable
(for **Windows NT/2000/XP**)
1. At the left bottom corner of your computer desktop, choose Start -> Setting -> Control Panel, and double-click System
2. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows
2000/XP select the Advanced tab and then Environment Variables.
3. For either User variables or System variables, click New and in the popup window, enter Variable name as CLASSPATH (note that all letters should be capital), and the directory where your JDK is installed as the Variable value.
For example:
If your JDK is installed at: C:\jdk1.4.1_06
Put the following line as the value:
C:\jdk1.4.1_06\bin;C:\jdk1.4.1_06\jre\bin;.
The first is where the java compiler 'javac' is, the second is the java run time environment 'java' is, and the final '.' denotes your working directory, so that the compiler and jre will find where your programs are. To be safe, you may also want to append the above line to then end of your PATH variable. Use ';' as the separator.
Save the variables, test the setting by opening a DOS prompt, type in
echo %CLASSPATH%
If your environment variables are set correctly, you should see your settings.
Or, you can just type in
javac
java
If your PATH and CLASSPATH is correct, windows should recognize those commands.
You do NOT need to restart your computer when installing Java.
Check whether TextPad and Java SDK work on your computer
Download HelloWorld.java into your local drive. Be sure that filename is case sensetive in JAVA programming.
Start TextPad, and open this HelloWorld.java file.
Click menu "Tools" ---> "Compile Java" to compile java file.
Click menu "Tools" ---> "Run Java Application" to run this file.
If you see "Hello World" in a DOS PROMPT window, that means there is no problem with your TextPad to compile/run Java program. Congratulations. You can start your java programming now. If you see some errors when run Java program, please click here to get more information.
For a more comprehensive description on how to setup Java environment on Windows machinese, please refer to the Sun document at: http://java.sun.com/j2se/1.4.2/install-windows.html
For **windows 7**: Follow this link http://www.abodeqa.com/2012/08/11/how-to-set-path/
Then : Start Compatible eclipse (e.g :64bit eclipse on 64bit os).
In Eclipse, select Windows | Preferences
Click the + in front of Java or double-click Java (after the +)
Click Installed JREs
Under the Name column, double-click jre1.5.0_08.
Click the Add External Jars... button.
In the Jar Selection window, navigate to your workspace folder, and double-click the file cs15-1xx.library.
In the Edit JRE window, click OK
In the Installed JREs window, click OK
Terminate (X) the Welcome window
You can always get it back by selecting Help | Welcome
Terminate (X) the Eclipse window.
For more Details follow this : http://blog.ajduke.in/2013/04/28/setting-up-new-java-compiler-and-runtime-in-eclipse-ide/
You can specify the target JRE when launching eclipse by with the -vm command line argument (either through a shortcut or in the eclipse.ini file).
Command line syntax: eclipse -vm c:\jre\bin\javaw.exe
eclipse.ini file syntax (use 2 lines)
-vm
c:/jre/bin/javaw.exe
You can also copy a given version of the JRE under your eclipse installation directory.
Generally speaking I would really advise against adding %JAVA_HOME%/bin to your SYSTEM path. In my experience, this usually leads to many unexpected behaviors. Far better IMHO to set the JAVA_HOME and add its /bin directory to the PATH through scripts/command line/shortcuts/etc. and invoke those when needed.
I'm working on setting up my development environment in Windows 7, installing Maven, etc. I've been running into path issues and have read, ad nauseum, other posts that pointed me in the right direction. My problem is, however, that my PATH variable (JAVA_HOME) isn't staying set.
When I try
mvn --version
I get
Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the location
of your Java installation.
So, I set it
set JAVA_HOME=C:\Tools\Java
and then mvn --version works. But if I close and then reopen the Windows terminal I just end up getting the original error. Super frustrating.
I've also added that path to the Environmental Variables in the Systems Settings (with the semi-colon spacing, etc) Path section.
You're only setting it within that shell. This is perfectly normal behaviour for environment variables - not just on Windows, but on other OSes too.
I don't know about Windows 7, but on Windows 8 if I press the Windows key and start typing "Environment Variables" I get an option to open the control panel applet for editing the user or system environment variables. That's where you want to put it. The right dialog looks like this:
If the method above doesn't get to it, you can use the System Properties dialog, which has a button near the bottom for it:
This is how the shell works in Windows, Mac OSX and UNIX and I suspect all operating systems.
Each prompt has it's own environment which is separate to any other process you have running. You can set a variable temporarily, but this is not saved to disk or preserved because you might set it in a script but you don't want it to affect the whole system.
If you want to change an environment variable in Windows you need to do Start -> Right Click Computer -> Properties -> Advanced Setting -> Environment Variables -> Add Property.
On Linux, you add your SET line to the ~/.bashrc file
To set environment variables in Windows, go to the System control panel (the quickest way is to right click Computer in the Start Menu and select Properties), and select Advanced system settings, and then Environment Variables...
Go to System ->Advanced System Setting ->Environment Variables. In System Variables, Click on New and provide the Following:
Variable name as : JAVA_HOME
Variable Value as :E:/JdkInstallions/Jdk1.7 (as on my system)
This should resolve the problem you are getting.
I'm on Windows 7 and I'm trying to set my JAVA_HOME path to use PhoneGap on android, when i create a project using the command line "cmd" it tells me that it can't find javac.exe? although i'm sure that I've set the variable right
here's my stuff:
Variable name: JAVA_HOME
Variable value: C:\Progra~1\Java\jdk1.7.0_17\bin
(I've also tried to use: C:\Progra~1\Java\jdk1.7.0_17\bin\javac.exe)
My javac.exe location on my laptop C:\Program Files\Java\jdk1.7.0_17\bin\javac.exe
and it still tells me that it can't locate the javac.exe
What I type to create the project and i meet this problem is this:
C:\Users\user>cd C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin
C:\Users\user\Desktop\phonegap-2.8.1\lib\android\bin>create.bat
Cannot locate javac.exe using the PATH environment variable.
Retry after adding directory containing javac.exe to the PATH variable.
Remember to open a new command window after updating the PATH variable.
Visit http://java.oracle.com if you need to install Java (JDK).
Also, i've tries restarting the windows and closing the command prompt and redownloading the JDK.
Thank You.
cmd is using the values from the PATH variable to locate javac :
set "PATH=%PATH%;C:\Program Files\Java\jdk1.7.0_17\bin"
For other softwares (Tomcat, Maven, etc.) JAVA_HOME must indicate the root of your JDK :
set "JAVA_HOME=C:\Program Files\Java\jdk1.7.0_17\"
No need to restart Windows. When using set the changes are taken immediately.
If you choose to modify those variables in the Control Panel, you have to close and relaunch cmd for the changes to take effect.
You have to add java
C:\Program Files\Java\jdk1.7.0_17\bin
Note that your path may be different.
to your environment variables and restart your console.
You can find how to set your variables here:
http://www.itechtalk.com/thread3595.html
Set the JAVA_HOME Variable
Right-click the My Computer icon on your desktop and select Properties.
Click the Advanced system settings. Click the
Environment Variables button. Under System Variables, click New.
Enter the variable name as JAVA_HOME.
Enter the variable value as the installation path for the Java Development Kit(C:\Program Files\Java\jdk1.7.0_17).
Click OK.
Click Apply Changes.
You might need to restart windows.
Set the JAVA_HOME environmental variable to
C:\Program Files\Java\jdk1.7.0_17
Press
Win + Break > Advanced System Settings > Environment Variables > System Variables
Modify/set JAVA_HOME to the above. (No need to restart)
I already had this error when I tried to create a new phonegap project for android but unfortunately I don't remember how exactly I have fixed this.
I don't know if you have followed the phonegap documentation so here is the link : new project, especially the part 3B (be careful about ; in your PATH).
If you don't know what to do now, maybe you should do it again step by step.
May be a little old, but since this is the first goolge result, I might as well add a little something.
You need to create the JAVA_HOME variable AND edit the PATH variable, adding ;%JAVA_HOME%\bin (with a ;) so cmd and some other apps can actually use javac and the rest of the tools