aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes quick question about exercise 1-1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "quick question about exercise 1-1" Watch "quick question about exercise 1-1" New topic
Author

quick question about exercise 1-1

Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

i skip #3 and compile both and it compile!

Step#3 is important. How did you compile ? Please show your command.


[My Blog]
All roads lead to JavaRanch
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Jan 07, 2011
Posts: 43
just the simple javac Apple.java and javac Fruit.java
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Ok. If you type "set" at the prompt, what does the variable called CLASSPATH look like ?
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Not that one. CLASSPATH, not PATH.
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
when i type "set" on cmd .... i havent find any Class Path
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Mmmhh... Do you have a "food" directory on your desktop with Fruit.class in it ?
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
Apple.java and Apple.class is on the desktop and Fruit.java and Fruit.class is on Food Folder
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

"food" folder is in c:\java, right ? Is there also a "food" folder on your desktop ?
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
i move it to desktop the food folder and on the desktop is the Apple
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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

Joined: Jan 07, 2011
Posts: 43
i dont get it

ill just skip this .. and go ahead...
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18850
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

We also have a FAQ about the CLASSPATH. Read it.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8815
    
    5
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.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Christian Joseph
Ranch Hand

Joined: Jan 07, 2011
Posts: 43
thanks guys!!!
Klebson Carneiro
Greenhorn

Joined: Aug 31, 2011
Posts: 3
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
 
jQuery in Action, 2nd edition
 
subject: quick question about exercise 1-1