Results 1 to 8 of 8
  1. #1
    TechTech is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Question (Help) Art and Science of Java Sample Code

    I'm unsuccessful at getting the sample code from the text book 'Art and Science of Java' to work on my Mac, 10.7, running Stanford's latest version of Eclipse. I can get Stanford's sample code working fine, just not the text book's code, which I found here: ftp://ftp.awl.com/cseng/authors/robe...Source%20Code/ and here The Art and Science of Java

    Any help would be appreciated. I'm completely new to Java, OOP, and Eclipse.

    I'm trying to get the sample code working, so I can see their Java version of 'hello, world', along with their other intro programs.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: (Help) Art and Science of Java Sample Code

    Please post the full text of any error messages and the source code that caused the error.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    TechTech is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: (Help) Art and Science of Java Sample Code

    Well, I'm basically unable to import the file structure into Eclipse. Since I'm completely new, I don't understand much at this point.

    The import dialogue of Eclipse says "No Projects are found to import" when selecting the folder with the files associated with it (downloaded from the links above). And the text in the book does not give any detailed instructions on how to access the files. I may have found some other related source code that may help, that enables me to import the files as a project.

    I'm not sure how to import and run just a .java and .class file and run them at this point.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: (Help) Art and Science of Java Sample Code

    Moved this to the IDE section
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    TechTech is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: (Help) Art and Science of Java Sample Code

    Thanks!

    I'm trying to find out what I need to do to compile this java file... (I'm completely new)


    /*
    * File: HelloProgram.java
    * -----------------------
    * This program displays "hello, world" on the screen.
    * It is inspired by the first program in Brian
    * Kernighan and Dennis Ritchie's classic book,
    * The C Programming Language.
    */

    import acm.graphics.*;
    import acm.program.*;

    public class HelloProgram extends GraphicsProgram {
    public void run() {
    add(new GLabel("hello, world", 100, 75));
    }

    }

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: (Help) Art and Science of Java Sample Code

    You will need the jar file with the acm package classes.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    stormed is offline Member
    Join Date
    Jul 2012
    Posts
    6
    Rep Power
    0

    Default Re: (Help) Art and Science of Java Sample Code

    Quote Originally Posted by Norm View Post
    You will need the jar file with the acm package classes.
    What are the steps required once you get this JAR file from the ACM taskforce website?
    Last edited by stormed; 07-23-2012 at 07:53 AM.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: (Help) Art and Science of Java Sample Code

    The jar file with the classes needs to be on the classpath for both the javac and the java commands.
    Both those commands have a commandline option: -cp
    you can use to specify the classpath the command can use. See the doc for the commands.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: 11-05-2011, 06:16 AM
  2. Replies: 1
    Last Post: 03-04-2010, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •