I am a new student in Java Programming and have been instructed to use JCreatorLE for my programming. However when i tried to do my assignment codes and saved it and ran it, it could compile fine but when it ran, it gave me an error of:
GE2001 Version 1.4
Error : Invalid Path, /bin/java.exe - classpath C:/Desktop/MainMenu
Press any key to continue - and it terminates the program.
When i saved my test program i used the file name MainMenu.java and the codes are below:
public class MainMenu
public static void main (Stringargs)
Scanner scan = newScanner (System.in);
System.out.print ("The Module Registration System Main Menu");
Plese advise me on what went wrong with my JCreatorLE as i have a deadline to rush which is rather pressing.
Thanks a million!
Campbell Ritchie wrote:So, what have you set your PATH to? And why did you set a CLASSPATH at all? Why are you keeping all your Java work on your desktop?
i don't get you? What do you mean by setting PATH? and classpath?
sorry for the questions cause this is really my 1st java program i'm testing out
That is your very first program, and you have never got one to run before? Which OS are you using? From the C: at the beginning, it looks like Windows.
I presume you have installed Java, which you download from here. You want what is called JDK 6 update 12. Not JRE. It should be 73MB to download. The update 12 is very new; I haven't seen it before. Install in the usual fashion, but when you get to the bit about "install in this folder?" you can install it wherever you like, but record carefully the exact name of the folder you installed it in.
You will need that for setting the PATH, which is described in the installation instructions. Remember you want JDK, not JRE. You will see something about setting the PATH permanently. Do what it says there. You will need the name of the installation folder, and you use that to make a PATH entry, which starts with the drive letter, usually C, and ends with bin. Remember: the slightest spelling error and it won't work. Test it by writing
at the command prompt. If you get something like "1.6.0_12" you have got it right. If you get "javac is not recognized . . ." you have not got it right.
When you installed JCreator it will have asked for your Java installation. You will probably have to tell it to look for a new installation now.
so I added C:\Program Files\Java\jdk1.6.0_12\bin to my PATH
This is what happens on my command prompt.
Note the awkward line wrapping.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Campbell>PATH
you were a great help
now i gotta slog through my assignment, hopefully will be able to scrape through. I have a lousy lecturer who speaks Martian
3. The School
class represents the Module Registration System in a school. It has three properties:
the schoolName (String), and two collection lists, namely moduleList(ArrayList of
modules) and studentList( ArrayList of students.
The class has the following methods:
䀁ؠaddStudent – This method accepts a Student object and adds it to the
䀁ؠaddModule – This method accepts a Module object and adds it to the
䀁ؠremoveStudent - This method accepts a int representing the studentID and
searches for the student within the studentList collection. It returns true when
the student is found, and removed from the studentList. Otherwise it returns
䀁ؠremoveModule - This method accepts a int representing the moduleID and
searches for the module within the moduleList collection. It returns true when
the module is found, and removed from the moduleList. Otherwise it returns
䀁ؠsearchStudent – This method accepts an int representing the studentID and
searches for the student within the collection of students. It returns the student
if found, otherwise it returns a null value.
䀁ؠsearchModule – This method accepts an int representing the moduleID and
searches for the module within the collection of modules. It returns the module
if found, otherwise it returns a null value.
䀁ؠlistModules – This method goes through the collection of the modules and
displays all the information of each module in the moduleList.
䀁ؠlistStudents – This method goes through the collection of the students and
displays all the information of each student in the studentList.
䀁ؠclassFull - accepts a moduleID (int) and checks if the classLimit for the
module has been reached.
䀁ؠisOfferedInSem - accepts a moduleID (int) and a sem (int). It checks if the
module is offered in the semester sem.
䀁ؠregisterModule – This method accepts a studentID (int), a moduleID (int) and
a semester (int). Returns true when the module is added to the module list in
the Student object. Otherwise it returns false.
䀁ؠListModulesTaken – This method accepts a studentID (int) and display a list
of modules taken by the student in the format shown below.
005 Tan Ah Teck
101 Programming Fundamentals
202 Intermediate Programming
What i have done so far is
Your method headings look correct to me, just on a very quick look, now you will have to work out for yourself what you write in the methods.
By the way: this looks very complicated for a "first" Java program. Please ask your teachers about how you are supposed to use an int to find a Student in a List. That seems an awkward bit of programming.
So the method headings are correct? May i ask what are constructors and how to declare one?
thanks for your advice.
A constructor heading starts with an access modifier (eg private, public: at your stage go for "public" until proven otherwise.
Then it has an identifier which is exactly the same as the name of the class.
The it has a pair of round brackets () which may or may not contain parameters.
You always miss out a return type for a constructor.