LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-18-2004, 01:44 AM   #1
lmellen
Member
 
Registered: Jan 2004
Location: Fairport, NY
Distribution: Arch/Ubuntu
Posts: 43

Rep: Reputation: 15
A very basic newbie question on Java


I've purchased "The Java Tutorial, Third Edition" . It was written for the j2sdk1.3 compiler. Iv'e downloaded j2sdk1.4_05 into FC2. Will the newer compiler not always work with the examples in the book? I'm working on a example called "CreateObjectDemo" that
creates a rectangle. The code:

Point origin_one = new Point(23, 94);
Rectangle rect_one = new Rectangle(origin_one, 100, 200);
Rectangle rect_two = new Rectangle(50, 100);

When I run javac the compiler gives me an error message that states:
"cannot resolve symbol"
It points to each Point and each Rectangle for 6 errors.
Here's the whole program:

public class CreateObjectDemo {

public static void main(String[] args) {

// Declare and create a point object and two rectangle objects

Point origin_one = new Point(23, 94);
Rectangle rect_one = new Rectangle(origin_one, 100, 200);
Rectangle rect_two = new Rectangle(50, 100);

// Display rect_one's width, height, and area

System.out.println("Width of rect_one: " + rect_one.width);
System.out.println("Height of rect_one: " + rect_one.height);
System.out.println("Area of rect_one: " + rect_one.area());

// Set rect_two's position

rect_two.origin = origin_one;

// Display rect_two's position

System.out.println("X Position of rect_two: " + rect_two.origin.x);
System.out.println("Y Position of rect_two: " + rect_two.origin.y);

// Move rect_two and display its new position

rect_two.move(40, 72);

System.out.println("X Position of rect_two: " + rect_two.origin.x);
System.out.println("Y Position of rect_two: " + rect_two.origin.y);

}
}

I guess I just need to know if I should use j2sdk1.3. It's on the disk that came with the book.
The compilers are not backward compatible? Sorry for the dumb newbie problem.
Thanks in advance -- Larry
 
Old 07-18-2004, 03:12 AM   #2
rgiggs
Member
 
Registered: Apr 2004
Location: berkeley, ca
Distribution: slk10, winxp
Posts: 313

Rep: Reputation: 30
i believe java is backwards compatible, so you should be OK. at least, right now, your problem is not compatibility; it seems to be something simpler:
does the example show you how to write the Point and Rectangle classes, too? if so, put the java files for those 2 classes in the same directory where the java file for your CreateObjectDemo class is. otherwise, they are library classes, and from the jdk1.4.2 api at http://java.sun.com/j2se/1.4.2/docs/api/index.html, you need to add the following lines to the beginning of the CreateObjectDemo file.
Code:
import java.awt.Point;
import java.awt.Rectangle;

Last edited by rgiggs; 07-18-2004 at 03:28 AM.
 
Old 07-18-2004, 11:51 AM   #3
lmellen
Member
 
Registered: Jan 2004
Location: Fairport, NY
Distribution: Arch/Ubuntu
Posts: 43

Original Poster
Rep: Reputation: 15
Many thanks rgiggs, You were right. I didn't have to import , I had to make a Point and a Rectangle class. The book is a little confusing.
One other quick question if I may? I notice your'e using slack 10? I burned a copy the other day. Are the alsa
utils, etc, etc now available? I was browsing somewhere and they were complaining that everything was still for 9.1
Thanks for the reply -- Larry
 
Old 07-18-2004, 12:09 PM   #4
rgiggs
Member
 
Registered: Apr 2004
Location: berkeley, ca
Distribution: slk10, winxp
Posts: 313

Rep: Reputation: 30
Quote:
Originally posted by lmellen
Are the alsa utils, etc, etc now available? I was browsing somewhere and they were complaining that everything was still for 9.1.
ummm... if you mean alsaconf, alsamixer... then yes. i din't use 9.1 much at all, so i don't know whether the alsa utils in 10 are newer versions. still, a few sound programs shouldn't prevent you from using a great distro.
 
Old 07-19-2004, 12:54 PM   #5
jpostma
Member
 
Registered: Jun 2003
Location: Alphen ad Rijn -- The Netherlands
Distribution: Fedora Core 2 - Slackware 12
Posts: 119

Rep: Reputation: 15
Eclipse is a good IDE for Java. You can easily determine and correct errors and exceptions.
 
Old 07-19-2004, 03:59 PM   #6
Earth
LQ Newbie
 
Registered: Jul 2004
Location: Boston, MA USA
Distribution: Slackware 10
Posts: 24

Rep: Reputation: 15
Quote:
Originally posted by jpostma
Eclipse is a good IDE for Java. You can easily determine and correct errors and exceptions.
It's also not the easiest IDE to dive into for learning java immediately.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Very basic newbie question regarding MySQL crispyleif Linux - Software 9 11-07-2005 11:13 PM
basic java programming question nkoplm Programming 3 09-22-2005 01:37 AM
basic newbie question about fluxbox lmellen Linux - Newbie 4 06-23-2004 11:55 PM
Your basic newbie question... rcarr Linux - Newbie 1 09-27-2003 02:46 PM
Basic Java arithmetic question chr15t0 Programming 2 07-05-2003 01:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration