Results 1 to 6 of 6
- 07-17-2011, 07:38 PM #1
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
- 07-17-2011, 08:15 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,380
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-17-2011, 08:29 PM #3
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?
- 07-17-2011, 08:52 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,380
- Blog Entries
- 7
- Rep Power
- 17
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:
Do that one directory level up from the yourpackage directory.Java Code:java -cp . yourpackage.YourClass
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-18-2011, 02:05 AM #5
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.
- 07-18-2011, 07:26 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,380
- Blog Entries
- 7
- Rep Power
- 17
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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Beginner Question About Packages, etc
By Humphrey Bogart in forum New To JavaReplies: 15Last Post: 03-24-2011, 04:45 PM -
Beginner - can't get through, mind looking at code and errors?
By hayden06f4i in forum New To JavaReplies: 8Last Post: 11-05-2010, 01:52 PM -
really quick question for beginner
By its_crawford in forum NetBeansReplies: 4Last Post: 06-17-2010, 04:14 AM -
Another beginner question for AP test
By DanK in forum New To JavaReplies: 1Last Post: 04-27-2009, 05:36 AM -
Beginner Java question
By DanK in forum New To JavaReplies: 3Last Post: 04-27-2009, 04:29 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks