Results 1 to 6 of 6
  1. #1
    Daimoth's Avatar
    Daimoth is offline Member
    Join Date
    Jul 2011
    Posts
    34
    Rep Power
    0

    Default Beginner question: errors appeared overnight

    I have a frustrating problem that probably has a simple, but unintuitive solution.

    I'm working in Eclipse, and I made a project and package to put all my newbie "learn the basics" java programs. Shut the computer down, went to sleep, got up, and now my project, package, basically everything except the java files themselves have x's, indicating errors. I have no idea what they are, or what happened. I changed nothing, but now I can't run any of my programs in this project in cmd, and I get complaints when I attempt to run any of them in Eclipse itself, although they still run properly if I ignore the errors, which are apparently outside the scope of these tiny little programs.


    Any help is appreciated, thanks.
    Last edited by Daimoth; 07-17-2011 at 08:15 PM. Reason: clarifying problem

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    You must've forgotten to save everything before you shut Eclipse down (you can change a setting to make it do so); for now go to Project > Clean ... next press F5 (rebuild from scratch). That should most likely solve it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Daimoth's Avatar
    Daimoth is offline Member
    Join Date
    Jul 2011
    Posts
    34
    Rep Power
    0

    Default

    Excellent, have some rep.

    So I saved my programs, but not the project that contained them? Will save all prevent this in the future?

    Also, I still can't run them in the command prompt. Is that because they're a part of a package?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Daimoth View Post
    Excellent, have some rep.

    So I saved my programs, but not the project that contained them? Will save all prevent this in the future?

    Also, I still can't run them in the command prompt. Is that because they're a part of a package?
    Yep, pressing Ctrl-Shift-S once in a while saves everything, but go to Window>Preferences>General>Startup and Shutdown and see what options are selected.

    Running a class in a package, say yourpackage.YourClass is easy:

    Java Code:
    java -cp . yourpackage.YourClass
    Do that one directory level up from the yourpackage directory.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Daimoth's Avatar
    Daimoth is offline Member
    Join Date
    Jul 2011
    Posts
    34
    Rep Power
    0

    Default

    Ah, I figured out what that problem was regarding that last bit. I added the actual package folders, individually, to the path environment instead of the folder that contained all the packages. I edited the path one folder up and now it works just fine. Unfortunately, the text book I'm learning out of was ambiguous about it, hence my confusion.

    I definitely appreciate that you took the time to help an absolute beginner. Thanks.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Daimoth View Post
    Ah, I figured out what that problem was regarding that last bit. I added the actual package folders, individually, to the path environment instead of the folder that contained all the packages. I edited the path one folder up and now it works just fine. Unfortunately, the text book I'm learning out of was ambiguous about it, hence my confusion.

    I definitely appreciate that you took the time to help an absolute beginner. Thanks.
    As you have figured out by now: you don't add package names to your classpath, but you add directories where those packages are stored instead. Better leave it all to Eclipse and run the stuff from Eclipse; it knows what it does and how to do it; if you want to run the stuff yourself from the shell/command line, do as I outlined in my previous reply. And it's true: quite some authors can't even program themselves out of a wet paper bag; they only wrote their books for the bucks and their books are full of errors. But I guess you understand how a classpath and packages work by now; oh, and welcome to these forums and thanks for the rep points ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Beginner Question About Packages, etc
    By Humphrey Bogart in forum New To Java
    Replies: 15
    Last Post: 03-24-2011, 04:45 PM
  2. Replies: 8
    Last Post: 11-05-2010, 01:52 PM
  3. really quick question for beginner
    By its_crawford in forum NetBeans
    Replies: 4
    Last Post: 06-17-2010, 04:14 AM
  4. Another beginner question for AP test
    By DanK in forum New To Java
    Replies: 1
    Last Post: 04-27-2009, 05:36 AM
  5. Beginner Java question
    By DanK in forum New To Java
    Replies: 3
    Last Post: 04-27-2009, 04:29 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
  •