I have written the following code (was a puzzle from “head first Java“)
The goal is for it to print out DooBeeDooBeeDo which I think I got right. I want to run this program now though and see it work how would I go about doing so? I have the JDK installed and working so dont worry about telling me that part. The book I am reading shows something like this (assuming you enter these commands in the cmd):
save: doobee.java
compile: javac doobee.java
run: %java DooBee
When I follow those instructions I get this in the cmd:
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\James>javac -version
javac 1.6.0_25
C:\Users\James>javac doobee.java
doobee.java:1: class DooBee is public, should be declared in a file named DooBee
.java
public class DooBee {
^
doobee.java:8: package system does not exist
system.out.print("Doo");
^
doobee.java:9: package system does not exist
system.out.print("Bee");
^
doobee.java:14: package system does not exist
system.out.print("Do");
^
4 errors
C:\Users\James>%java doobee
'%java' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\James>
So how can I get my very simple first program to run?
Rename doobee.java to DooBee.java, and change
system.out.printtoSystem.out.print. Java is rather case-sensitive.