aspose file tools*
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 Spring in Action this week in the Spring 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: 39409
    
  28
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: 39409
    
  28
. . . and look at this FAQ.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to run a java program