Results 1 to 7 of 7
  1. #1
    kwamifolds is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default configuring Eclipse for Art and Science of Java exercises

    Hi!!! I know this was discussed in another thread on this website but I can't find it now that I've registered...

    I'm doing the Stanford / iTunes U Programming Methodology Course, reading "The Art and Science of Java" and using Eclipse (the stanford version and also toying with a newer version)

    I want to do the exercises in the book but every time I try to get the code up in Eclipse it tells me my classes don't exist or whatever. Yes I have imported the acm.jar file and it still goes weird.

    I'm just trying to run "Hello World." I've imported EVERYTHING from the acm.jar for my project. It keeps telling me it doesn't recognise the classes I want to use. Here's the code from the book I'm trying to plug in:



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

    public class HelloWorld extends GraphicsProgram {
    public void run() {
    add(newGLabel("hello, world", 100, 75));
    }
    }


    Sorry for the n00b question but I just want to get this up and running so I can do the exercises! This book wasn't cheap. Eclipse is completely confusing for someone just learning this stuff.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Is the acm.jar library on the classpath?

  4. #4
    kwamifolds is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Quote Originally Posted by doWhile View Post
    Is the acm.jar library on the classpath?

    I'm not sure! How do I do that? For the record I did search "classpath" in the Help tab (before this thread) and nothing came up.

  5. #5
    kwamifolds is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Alright I googled the bejesus out of how to make a classpath and still no dice.

    Here's what I do in eclipse (latest version):

    Create a new java project
    Import Archive File -> import acm.jar into my only project folder
    Create a new class which I'm calling HelloWorld.java
    Fill that class with the previously mentioned code, verbatim
    Right click on the acm, click on the "Build Path" menu, select "Use as source folder"
    Then all the error messages go away from the code in HelloWorld.java
    I try to Run this and get the messages:

    Start: applet not initialized
    and in the bottom window on eclipse I see:

    java.lang.ClassNotFoundException: HelloWorld.class
    at sun.applet.AppletClassLoader.findClass(AppletClass Loader.java:211)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
    at sun.applet.AppletClassLoader.loadClass(AppletClass Loader.java:144)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 47)
    at sun.applet.AppletClassLoader.loadCode(AppletClassL oader.java:662)
    at sun.applet.AppletPanel.createApplet(AppletPanel.ja va:807)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java: 714)
    at sun.applet.AppletPanel.run(AppletPanel.java:368)
    at java.lang.Thread.run(Thread.java:680)
    load: class HelloWorld.class not found.


    Why did I get a .java file when I clicked "create new class" instead of a .class? WHat am I missing?

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Quote Originally Posted by kwamifolds View Post
    Why did I get a .java file when I clicked "create new class" instead of a .class? WHat am I missing?
    The fundamentals, which you can learn here: Trail: Getting Started (The Java™ Tutorials)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: configuring Eclipse for Art and Science of Java exercises

    Why did I get a .java file when I clicked "create new class" instead of a .class? WHat am I missing?
    If you are this new to java programming, I highly recommend against using Eclipse, but rather use the command line as explained in the the link in post 6. If you forge directly into Eclipse, you will miss many fundamental concepts. If you insist on using Eclipse, there are ample examples for how to add libraries to the classpath: Project Properties -> Java Build Path -> Libraries.

Similar Threads

  1. Configuring Java source folders for eclipse
    By kfir.wolfson@gmail.com in forum Eclipse
    Replies: 8
    Last Post: 10-01-2010, 12:11 PM
  2. Configuring tomcat in eclipse
    By divya.anupindi in forum Advanced Java
    Replies: 1
    Last Post: 09-10-2009, 08:37 AM
  3. Configuring PMD in eclipse
    By UmaMuthu in forum Eclipse
    Replies: 1
    Last Post: 08-21-2009, 01:12 PM
  4. Configuring Jboss with Eclipse
    By javaplus in forum Advanced Java
    Replies: 3
    Last Post: 05-07-2009, 11:16 AM
  5. configuring eclipse
    By doug99 in forum Eclipse
    Replies: 0
    Last Post: 03-09-2009, 07:32 PM

Tags for this Thread

Posting Permissions

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