开发者

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

开发者 https://www.devze.com 2023-03-08 18:47 出处:网络
I have written the following code (was a puzzle from \"head first Java\") http://pastebin.com/9RmyUqZr

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>

S开发者_开发技巧o how can I get my very simple first program to run?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号