I'm trying to get the command prompt to run Java from a notepad saved file. I have a little programming background with Game Maker. One of my students wants to create Mine Craft mods so we're learning Java together.
We're going through the Java tutorials on their website: https://www.tutorialspoint.com/java/java_basic_syntax.htm
I've set the environment variable path to: C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin
I've created a folder in C:\Users\Ryan\Java and that's where I am in the command prompt. When I type java MyFirstJavaProgram I just keep getting this 'java' is not recognized as an internal or external command, operable program or batch file.
Any suggestions what I'm doing wrong?
I appreciate the help!
navigate to the c:\Program Files\java\jdk\bin and see if there really is a "java.exe".
try calling it with the full path:
\Program Files\java\jdk\bin\java.exe MyFirstJavaProgram
and let us know if any of those work.
So I'm confused about an error getting to the java command. The path would have been set or found for the javac command to have been executed.
Ryan Daniele - Does this website have good learning tools/examples?
I don't think that they web site has any online tutorials, but many if you were to search this site I'm sure that you would find people mentioning and/or linking to sites on the web or books etc.
Java is also rather large with many different areas/specialties, much like programming itself. You may want to either open up your mind to narrow your focus, depending on what exactly you are planning on doing.
Some people have come to this web site for help with Java certification, others have come solely to help other people out and still others came post questions to problems (usually fairly specific) or to read and learn from the community posts.
If you are trying to get into Java then you may want to look into the book titled Head First Java.
Once you can navigate your way though the different loops (for, do, while) and decision constructs (if/else/switch) you may want to start learning methods, classes and then other object orientated programming.
Do not be discouraged when learning Java or programming for that matter. Nearly everyone started out printing something like "Hello World" to the screen and everyone makes mistakes, some more then others. It's though making mistakes that you learn (or hopefully learn eventually).
Programming is something that is usually easy to start, but difficult to master.
I'm having problems getting it to work on my students laptop. I'm using Windows 7, he's using Windows 10.
I downloaded the java jdk-8u144-windows-x64.exe from this website on both computers but I changed the folder name to just jdk: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Both of our Environment Variable Paths are: C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin
Both of our java folders are c:\Users\Java
But when I type javac MyFirstJavaProgram.java for him, it says 'javac' is not recognized as an internal or external command, operable program or batch file
I'm able to compile and run it on my computer just fine. I hope the pictures I attached are helpful.
Thanks for the help,
But I changed it to match the path it should be, just to test it. It didn't work either way.
Open a command prompt window and enter: PATH to see the contents of the PATH variable.
That is the value the install of the JRE adds to the PATH.
This should be the location of the javac file on the system in question.
When you get a chance please do that and paste the results in your reply.
As well in your reply can you paste the results of the following command echo %java_home%
You may not have a java_home defined, which is fine. This is not always needed.
Please note that after you change the path, you may need to close the command prompt and open up a new one for the results to be noticed.
Being a Windows system you can do either
and you will get the same result.
So I have a feeling I need to delete or disable all of those extra paths. But they were already there and I'm afraid to delete things if I'm not sure if it will mess up anything else.
Should I delete everything except the one for java?
I'm not sure what the echo %java_home% did, after I typed it in it just said that same thing on the next line.
they were already there and I'm afraid to delete things if I'm not sure if it will mess up anything else.
I wouldn't change anything that you didn't enter. The OS uses PATH to find executable files when the path to the file is not given. There are probably programs on your PC that require PATH.
I don't know what programs use the JAVA_HOME variable. I don't think the JDK or JRE use it. Maybe its used by some IDEs.
It would be more useful if text were posted instead of images. The contents of images can not be copied to include in responses.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
And I'm assuming we need to get it to say what mine says when I type in path.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.
PATH="C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin";"C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin";C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Hewlett-Packard\SimplePass\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;"C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin";
PATH="C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin";"C:\WINDOWS\SYSTEM32; ...
I think proper positions for the "s would be:
PATH=C:\WINDOWS\SYSTEM32;"c:\Program Files\java\jdk\bin";C:\WINDOWS\SYSTEM32; ...
Windows 7, Service Pack 1 6.1.7601
I set up the path following this tutorial website: https://www.tutorialspoint.com/java/java_environment_setup.htm
On my Windows 10 Pro system I have zero quotes in the path variable as noted here (get ready it's a long one):
Note that in on line 12 I have the directory where javac is located and everything works fine for me.
I know that I probably have more then you and more then what is needed.
I just thought I'd show you mine to show you quotes are not needed for this to work.
I think that the issue that you are experiencing is the quotes.
If you take them out of yours or your students path you should be set I think, providing you are pointing to the correct directories that is.
I tried adding a path to PATH with "s before and after the path and it worked, but the "s were stripped off when it was saved.
I don't know what Windows is doing or why some paths are wrapped in '"s and some are not.
The problem with what you posted was that several paths were within one pair of "s instead only a single path within a pair of "s.
I don't have any ideas why that could happen.
Here is my PATH with a small edit to end each line with a ;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;
C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
"C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\";
"C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\";
C:\Program Files (x86)\Skype\Phone\;C:\BatchFiles;C:\Users\Norm\AppData\Local\Microsoft\WindowsApps;
This is very odd. It seems like it should be super simple.
C:\Users\Spence\Java> javac MyFirstJavaProgram.java
'javac' is not recognized as an internal or external command, operable program or batch file