• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

running java at the command line

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 10
2
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With what name have you saved your file.It should be same class name which have the main method.You can check this once.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :-)
 
Marshal
Posts: 76433
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

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.
 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic