Hi guys I am just learning Java and I am have a problem running programs at the command line. I have the following code:
I can run this program in net beans were I originally wrote the program and it runs fine there. I also compile the program at the command line using javac but when I go to run this program I get a error message that it cant find main. I was wondering if the problem is because there is more than one class? any ideas would be great
Which command are you typing at the command line? In which directories are the class files? Due to the package, they should be in a subdirectory called "java_help".
By the way, you should start all class names with an uppercase letter, not use underscores in class names (use CamelCase instead), and not use underscores in package names either (they should be all lowercase). That is, if you don't want to confuse others reading your code, because those are the conventions everybody uses :-)
I can see you have programmed in C, by the use of _ in your identifiers. Only use _ in CONSTANT_NAMES or in a few circumstances in package names. You should remove every _ from your code and change the names to mixedCaseLikeThis, as Ulf has already told you.
I am afraid your methods are too long, and should be divided up.Unlike in C, you should not have anything real in the main method; simply use it to start the app off. You can get it down to 1 line. I am surprised you are using System.in.read; you must have an old book. I think read() is a particularly useless method, and you should use a Scanner to read from the keyboard; there is an example in the Scanner documentation.