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)
Bobby Smallman
Ranch Hand
Joined: Sep 09, 2010
Posts: 107
posted
0
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.
Everyday in every way, we get a little better.
Zach Williams
Greenhorn
Joined: Nov 07, 2010
Posts: 9
posted
0
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
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.
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 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
Joined: Nov 07, 2010
Posts: 9
posted
0
great, thanks for your help!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Command Prompt error- Can't run through compiler