Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

quick question about exercise 1-1

 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just bought the book of scjp by sierra and bates

uh i got question in the early topic, so embarasing

1. createthe super class as follows




so i create one and put it on the directory c:\java\food folder

2. create the subclass in a separate file as follows:


so i also create a seperate class, i put it on my desktop



3. Create a directory called food off the directory in your class path settings

i got stuck on this one

4. attemp to compile the two files. if you want to use the Apple class, make sure you palce the Fruit.class file in the food subdirectory

i skip #3 and compile both and it compile!....



whats the meaning of #3?
am i correct?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i skip #3 and compile both and it compile!

Step#3 is important. How did you compile ? Please show your command.
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yap i skip it...

1st i put this on c:\java\food folder



2nd i do this nad put it on my desktop(so its on different folder)


so i compile it. both create a new file called Fruit.class and Apple.class
is that it?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was asking you to show me how you compiled your classes Please show me the things you entered at the command prompt.
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just the simple javac Apple.java and javac Fruit.java
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. If you type "set" at the prompt, what does the variable called CLASSPATH look like ?
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Path=C:\Program Files\Common Files\Microsoft Shared\Win
s (x86)\Common Files\Microsoft Shared\Windows Live;C:\W
s;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsP
m Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\P
s Live\Shared;C:\Program Files\Java\jdk1.6.0_22\bin

is this it?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not that one. CLASSPATH, not PATH.
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i type "set" on cmd .... i havent find any Class Path
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmmhh... Do you have a "food" directory on your desktop with Fruit.class in it ?
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apple.java and Apple.class is on the desktop and Fruit.java and Fruit.class is on Food Folder
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"food" folder is in c:\java, right ? Is there also a "food" folder on your desktop ?
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i move it to desktop the food folder and on the desktop is the Apple
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why it's working. The default classpath is the current directory ".". If the "food" folder was not in the same directory as your Apple.java file, you would need to do step#3 too. Checkthis tutorial to know more about the PATH and the CLASSPATH.
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont get it

ill just skip this .. and go ahead...
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christian Joseph wrote:i dont get it

ill just skip this .. and go ahead...


This is not one of those sections that you should skip (for very long). You are going to need to understand classpaths, especially you start coding application that have more than one class (and packages).

Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We also have a FAQ about the CLASSPATH. Read it.
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The K&B book assumes that you already have your system environment stuff set up for Java. In addition to the links already suggested, you could skip ahead to the development chapter (chapter 10 I think). It talks more about this stuff.
 
Christian Joseph
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys!!!
 
Klebson Carneiro
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bert Bates wrote:The K&B book assumes that you already have your system environment stuff set up for Java. In addition to the links already suggested, you could skip ahead to the development chapter (chapter 10 I think). It talks more about this stuff.


Yes, that's true. But I use Eclipse for my projects and I had never set my CLASSPATH, it was blank till today. I just had to add "." in the CLASSPATH for my code to work :P
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic