• Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie, can't compile and one other dumb question  RSS feed

 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Just getting started and I can't compile. I'm guessing by reading other posts something is wrong with my PATH but I can't seem to figure it.

I've changed the path in the command prompt to the folder where the source file is: Documents\Java Practice - the file is MyFirstApp.java.

I've changed my path to "C:\WINDOWS\Program Files\java\jdk1.8.0_60\bin;" - I've used both single and double quotes around the path. I read in another post that because Program Files has a space I needed double quotes.

I have both jdk1.8.0_60 and jre1.8.0_60 in my Java directory under Program Files. In jdk1.8.0_60\bin I also see java and javac.

When I type javac MyFirstApp.java in the command prompt I get: 'javac' is not recognized as an internal or external command, operable program or batch file.

Other question: I have a program called Oracle Java Mission Control. If I use Notepad++ to code and the command prompt to compile and run the code, what will use this program for??

Thanks,
Stace

PS - I'm on Windows 8 platform.
cp.png
[Thumbnail for cp.png]
command prompt
explorer.png
[Thumbnail for explorer.png]
explorer
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't worry; about 80% of us had that same error message when we first tried writing Java®. And the other 20% didn't use Windows
That error is caused by not setting your PATH environment variable. Nil desperandum; we have an FAQ which tells you how to set your PATH (there are other ways to do it, which you can find in the installation instructions from Oracle). Five minutes setting up the computer, a new command line window, and you will be up and running

Remember the new PATH entry should go at the beginning of the existing PATH. Don't change the remainder of it. If there is not already a CLASSPATH variable, don't create one.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you did install Java® in its usual location
C:\Program Files\Java\jdk1.8.0_60\bin
Please show us what happens when you write
echo %PATH%
and
echo %CLASSPATH%
(The latter should not output anything.)

In which case you should not have \WINDOWS in your PATH entry.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read about Mission Control here. It seems to be a low‑level memory analyser, which you will probably not need until you are running large apps with millions of objects.
 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I get with the echo commands.

ps - I changed the path based on the instruction link from the first reply - C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Program Files\java\jdk1.8.0\bin
echo.png
[Thumbnail for echo.png]
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be C:\Program Files\java\..., not C:\WINDOWS\Program Files\java\....
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
…and you should have the new element at the beginning of the PATH.
You must open a new command line window before the new PATH is operational.

Try this at the command line
set PATH="c:\Program Files\Java\jdk1.8.0_60\bin";%PATH%
and see whether that works. But check it for spelling errors first.
 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I took out \WINDOWS from that path. Still got the same error.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try my instruction beginning “set”.
You have to open a new command line window.
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... or type cmd.
 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DUDE! I got something new!!! Ok, I still think something is wonky, but I'm feeling progress!!! Check this out:
new-error.png
[Thumbnail for new-error.png]
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good news. The compiler is working.
Change { to ( in front of String.
 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changed the curly to a paren. I didn't get an error, but I also didn't get the output.

My code is:

public class MyFirstApp {

public static void main (String[] args) {
System.out.println("I Rule!");
System.out.println("The World!");
}

}
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to run the application:
java MyFirstApp
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use cut‑and‑paste rather than screenshots to post your error messages.
 
Stacey Christiansen
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duh. Wow.

THANK YOU SO MUCH!!!

It worked!! WOOT!! Thanks to both of you so much!! I'm probably a little too excited about this.

Stace
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing wrong in being excited.
Programming is fun :-)
Your enthusiasm deserves a cow :-)
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Ryan Gabriel
Greenhorn
Posts: 20
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A while ago, I got stuck in the JDK, JRE mystery.
What I did instead searching over internet. I uninstalled and re-installed Java, but in a different directory other than C:\WINDOWS\Program Files\java\.
After that I got a clear understanding with environment variable and how it works (pretty much )
Before that I was like
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But we already know that it isn't c:\WINDOWS\Program Files\…

The JRE runs Java® programs and the JDK allows you to create them too. The JRE programs are all included in the JDK.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!