James
James

Reputation: 35

just started learning Java and wan to know how to run my first application

I have written the following code (was a puzzle from "head first Java")

http://pastebin.com/9RmyUqZr

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?

Upvotes: 0

Views: 297

Answers (2)

Sebastiaan van den Broek
Sebastiaan van den Broek

Reputation: 6361

Part of your problem is not using capital letters for the word 'System', so apparently it tries to find a package instead. So use System.out.println("");

And capitalize your class name.

Upvotes: 1

Owen
Owen

Reputation: 1561

Rename doobee.java to DooBee.java, and change system.out.print to System.out.print. Java is rather case-sensitive.

Upvotes: 2

Related Questions