• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to do the first exercises

 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok ive been trying to do the first exercises in the head first java book the one with the party and the one with the dog i input the source code onto the notepad and i save it as an all file not a txt then i click on it but all it does is open the notepad agian what am i doing wrong?!?!?!?!!?
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the Head First Java book, but I think the step you're missing here is compiling the file. You save it as an "all" file, which I think means you tell Notepad not to save it as a text file (with a txt extension). That's good. You are saving it with a Java extension too I hope. Anyway, the book must teach how to compile and run a Java application. It's not just a matter of clicking on the file.
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware: the party is an incomplete application; you can compile it but it won't run.

And welcome to JavaRanch
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you are probably better off not using NotePad. Download Notepad2, NotePad++ or jEdit, which are all much better than NotePad for programming.
 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey everyone sorry i couldnt get back sooner ive had a pretty hectic past couple of days. Anyway thank you all for all your help suggestions and im going to try it out agian right now and see if I do it right. Once agian thanks!
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rusty Gordon wrote:hey everyone sorry i couldnt get back sooner ive had a pretty hectic past couple of days. Anyway thank you all for all your help suggestions and im going to try it out agian right now and see if I do it right. Once agian thanks!


No one mentioned it, but you said you are saving it as an "all" file. Whenever you save a Java program, save it as "PublicClassName.java" where PublicClassName is (usually) the name of your top level public class. If the file isn't a .java file the compiler will yell at you when you try to compile it.
 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so i downloaded jedit not using notepad anymore so now what?
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rusty Gordon wrote:ok so i downloaded jedit not using notepad anymore so now what?


I'm going to recommend going through this tutorial. It should help with basic programming, saving, compiling, and running a java program.

Note I linked the Windows version, but there are other versions on that site for other OS's too.
 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
W. Joe Smith wrote:
Rusty Gordon wrote:ok so i downloaded jedit not using notepad anymore so now what?


I'm going to recommend going through this tutorial. It should help with basic programming, saving, compiling, and running a java program.

Note I linked the Windows version, but there are other versions on that site for other OS's too.



thanks ill take a look at it
 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so im following the tutorial but everytime i type cd C:/java another cmd screen flashes up the immediately closes whats up with that?
 
Rusty Gordon
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so when im trying to do the exercise whenever i go to cmd i cant change it from C:\Documents and Settings\localuser>
I enter cd C:\java but i still get an error message i have tried everything i can think of grr its so frustrating!!
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you get an error The system cannot find the path specified. ?

If you do, try typing cd c:\java

notice the difference in the slash


edit: sorry, I see you have that covered. Still, what is the error message you get? when you try to change directories?
 
Campbell Ritchie
Sheriff
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your "java" directory. Try moving it into "My Documents" bcause the command line on Windows usually opens with "My Documents" as its default location. Then try

cd java

If you are getting error messages (as Fred Hamilton has told you) make sure to tell us what they are.

Are you still getting windows appearing and disappearing? No idea what causes that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic