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.
Related
I Create a Sample for lunch whatsapp with appium and C# .NET
static void Main(string[] args)
{
Console.WriteLine("Hi");
AndroidDriver<AndroidElement> driver;
DesiredCapabilities capabilites = new DesiredCapabilities();
capabilites.SetCapability("deviceName", "Google Nexus 5 - 5.0.0 - API 21 - 1080x1920");
capabilites.SetCapability("platformversion", "5.1.0");
capabilites.SetCapability("platformname", "Android");
capabilites.SetCapability("appPackage", "com.whatsapp");
capabilites.SetCapability("appActivity", "com.whatsapp.Main");
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilites);
//com.whatsapp:id/registration_phone
driver.FindElement(By.Id("com.whatsapp:id/registration_phone"));
Thread.Sleep(10000);
driver.Quit();
}
I start appium, I can get my device and I can see my device in ui automator viewer .
But when I Run My Program I get this Error on this Line :
and I set PATH and ANDROID_PATH :
ANDROID_PATH : C:\Users\user\AppData\Local\Android\sdk
PATH : %PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
all of them are correct and true
I guess this problem becuse i have more than one SDK
1. for android studio : C:\Users\user\AppData\Local\Android\sdk
2. for eclipse : C:\android\sdk\android
How I can chose a specific SDK location for my C# program .
you can also go into Eclipse --> Run Menu--> Run Confiuguration -->Environment Tab--> ANDROID_HOME --> Give Path to the SDK folder
Also as other suggested set your path variable. Taken from https://www.java.com/en/download/help/path.xml
Windows Windows 10 and Windows 8
In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH
environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close
all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows 7
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH
environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close
all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows Vista
From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH
environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close
all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
Windows XP
Select Start, select Control Panel. double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH
environment variable does not exist, click New.
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close
all remaining windows by clicking OK.
Reopen Command prompt window, and run your java code.
SET Environment variables in Eclipse(IDE) locally with ANDROID_HOME and then try to run...it worked fine for me
You can write BAT file for starting appium process. Inside of this batch file write SET ANDROID_HOME = blabla, it will override system variable.
Check if system32 is present as path variable
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
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.