This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes why cant i start my program in the console? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why cant i start my program in the console?" Watch "why cant i start my program in the console?" New topic
Author

why cant i start my program in the console?

kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
run, cmd and type :

java myprogram

i am on the right directory that my class file is.
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
The class name is case sensitive - even in a Windows environment. Does your class start with a capital letter?
[ September 22, 2005: Message edited by: Steve McCann ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
What kind of error message do you get? (Word af advice: Don't just say "it doesn't work" or "it doesn't start", say specifically what you're doing, what you expect to happen, and what actually happens, including all error messages.)

Is the current directory part of the classpath? Maybe you need to type "java -classpath . myprogram"


Ping & DNS - my free Android networking tools app
Phil Dixon
Greenhorn

Joined: Aug 13, 2005
Posts: 11
Kelvin,

Have you compiled your program?

javac Myprogram.java

Oops. Just noticed you put 'class file' in your post.
The excitement of my first reply to a post got the better of me!
[ September 22, 2005: Message edited by: Phil Dixon ]
kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
i get this message :

'java' is not recognized as an internal or external command,
operable program or batch file.
Aly Gilani
Greenhorn

Joined: Jul 20, 2004
Posts: 7
Originally posted by kelvin cheung:
i get this message :

'java' is not recognized as an internal or external command,
operable program or batch file.


Hi Kelvin,

I think your PATH variable is not set properly.



make sure you have C:\<JDK>\bin directory in the path.

HTH,

Aly
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
As you work through this, see if THIS helps. I'm looking for feedback on how to make it better, so let me know if it doesn't!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
oh yeah.
i did not know that I needed to set the path.
thank you all!

by the way,
Stan James: you got a very helpful page!
it did help me, seriously! thanks
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Stan James:
As you work through this, see if THIS helps. I'm looking for feedback on how to make it better, so let me know if it doesn't!


That's a great reference. You should add a link to it from the JavaRanch FAQ.

Layne


Java API Documentation
The Java Tutorial
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: why cant i start my program in the console?
 
Similar Threads
What UML Tool(s) are you using for SCEA Beta Part II?
Which RSS reader do u use?
Beta Part II submission acknowledgement
Convincing the management
prisoner problem