Problems with java and javac commands? Do the following

This is a branch from the usual discussion about java. You don’t really need this if you didn’t have any errors when executing the java –version and javac –version commands in the last post. You probably also don’t need it if you’re using an IDE since the commands are run internally for you. Now, let’s start sorting things out.


The windows command prompt has inbuilt commands. You can also run other executables from the command line as long as the command prompt knows where to find the executables. In order to find the executables, it searches the current directory in which you are and also the path (which is just a list of directories you specify). If the javac –version command doesn’t run, it is likely you have not included it in your path. Let’s do that now.


Even though I strongly advise you to do this yourself by following either method 1 or 2, I have included a small utility written in python to search for your java installation and add it to the path for you. You can find this in method no 3

Method 1: Using the command prompt

1. Open an elevated command prompt window (press Windows key to open the start menu, type cmd, right click on the cmd and select run as administrator)

run

2. Type path. The output you get are the list of search folders in which command prompt looks for commands or executables

path

3. Type setx PATH "%path%;%ProgramFiles%\Java\jdk-9\bin" /m and press enter (If you have installed another version of java, the jdk-9 part will have to change. If you installed the 32 bit version of the jdk on a 64 bit version of Windows, the %ProgramFiles% will have to change. You can also just open a folder and navigate to the location of the installation of the jdk and copy the path to the directory. It should look something like C:\Program Files\Java\jdk-9\bin)

addPath


4. Type setx JAVA_HOME %ProgramFiles%\Java\jdk-9 /m and press enter

javaHome

5. At this point, you’re done. Now we have to check to see if everything worked. Type start and in the new command window, type the javac –version command and press enter. If it gives you the right version of java installed, you’re really done. Otherwise, the path you specified was incorrect.


Congratulations, you’re done.


Method 2: Using the Advanced System Settings dialog

1. Open a folder and navigate to the jdk folder. Copy the path to the folder from the address bar

copyPath

2. Open the run dialog and type sysdm.cpl. This should open the system properties dialog box

runsysdm

3. Switch to the advanced tab and click on environment variables

advanced

4. Under the System variables, locate the variable named path and edit it

envViriables

5. Paste the path you copied into the value column at the end of the values that already exist. Make sure there is a colon ; separating the previous entries from the current one. (On the latest build of windows 10 as you can see below, you need to click New and paste into the empty field)

path2

6. Press OK

7. Click New under the System variables and type the variable name: JAVA_HOME. Under the variable value, paste the copied value there without the \bin at the end.

8. Click OK to close all the open dialogs.

9. Restart all command prompt windows and the changes will take effect.


Method 3: Using a script

You can use this utility as a last resort if all else fails. It is written in python and compiled to run on windows.

If you already have python installed and configured on your windows system, I encourage you to use the python source instead, else, you can use the windows executable instead.


Website

Windows executable (.exe)

Python Source code (.py)

ShareFiles https://staphyinc.sharefile.com/d-sc74090bc68f47019 https://staphyinc.sharefile.com/d-s23847cf687040008
DollarUpload https://dollarupload.com/dl/77821d88 https://dollarupload.com/dl/4b437
DepositFiles https://depositfiles.com/files/1qn3nmdug http://depositfiles.com/files/0b47qm4qd


If the javac –version command still does not work after religiously following all methods, herein and google can’t help much (your problem may be spiritual, but nevertheless, we can try to do something about it) you can use the comments section below to get more help or contact me directly.


You can continue with the discussion here.

Comments

Popular posts from this blog

How to use the WhatsApp File Sharer app

Whatsapp file sharer becomes SA File Sharer

WhatsApp File Sharer