This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to run a java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to run a java program" Watch "How to run a java program" New topic
Author

How to run a java program

Mohnish Khiani
Ranch Hand

Joined: May 17, 2010
Posts: 65
whenever i have to run a java program in the command prompt i have to set the current directory to the bin folder inside the java folder's jdk folder.i also have to save my programs in the bin folder to run them.What should i do if i have to save my programs somewhere other than the bin folder in the java folder and also run these programs from command prompt.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41098
    
  29
It is usually a very bad idea to save your own work inside the bin folder. When you open the command line try this (or similar)
mkdir java_work
cd java_work
Don't save anything in bin.
The next time you will only need
cd java_work
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41098
    
  29
. . . and look at this FAQ.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14601
    
  25

You have to add the bin directory of the JDK to the PATH environment variable. You can read how to do that in the JDK installation instructions, step 4 (Update the PATH variable). Note that you have to close and re-open the command prompt window after changing the variable.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Mohnish Khiani
Ranch Hand

Joined: May 17, 2010
Posts: 65
thanks every one..i got it
 
Don't get me started about those stupid light bulbs.
 
subject: How to run a java program