Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Command Prompt error- Can't run through compiler

 
Zach Williams
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I literally just picked up the book last night to start learning Java. I am using Head First Java 2nd Edition. Part of the first chapter has me writing some simple coding.

However, I am having trouble getting the compiler to work. First off, it wont recognize any commands when I use javac. It only recognizes commands that begin with java, like "java -version"

But when I attempt to run this through the compiler using this command.

>java MyFirstApp.java

I get this error from command prompt (see attached)

java help.png
Command Prompt error
[Thumbnail for java help.png]
 
Bobby Smallman
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a classpath issue, make sure your classpaths are set correctly, if you did them manually it is pretty easy to miss a typo the first type you do it.
 
Zach Williams
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can it still be a classpath issue if I am able to issue the command "java -version" and it is able to display the correct version? I copied the path directly from the location of the /bin file so i dont think I have any typo's
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. No, it's not a CLASSPATH issue at all. It's a PATH issue.
2. You don't run a java source code file with java.exe. It has to be compiled with javac.exe.

Recommended reading:
http://download.oracle.com/javase/tutorial/getStarted/problems/index.html
 
Henry Wong
author
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zach Williams wrote:
But when I attempt to run this through the compiler using this command.

>java MyFirstApp.java

I get this error from command prompt


The JVM (java command) takes the name of the class to run. In this case, you are trying to run the "java" class, in the "MyFirstApp" package. Perhaps you meant...

> java MyFirstApp

Or if you are trying to compile, then you probably mean...

> javac MyFirstApp.java

Henry
 
Zach Williams
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my path is defined as

C:\Program Files (x86)\Java\jre6\bin

the location of my bin is

C:\Program Files (x86)\Java\jre6\bin

Javac is still coming up as not recognized as internal or external command...
 
Henry Wong
author
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zach Williams wrote:my path is defined as

C:\Program Files (x86)\Java\jre6\bin

the location of my bin is

C:\Program Files (x86)\Java\jre6\bin

Javac is still coming up as not recognized as internal or external command...


javac is not recognized because you never install the compiler. The JRE is only the runtime environment -- it doesn't include the compiler. See if you have a JDK installed, and if not, install one.

Henry
 
Zach Williams
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
great, thanks for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic