File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 38818
    
  23
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: 38818
    
  23
. . . and look at this FAQ.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14149
    
  18

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 7 API documentation
Scala Notes - My blog about Scala
Mohnish Khiani
Ranch Hand

Joined: May 17, 2010
Posts: 65
thanks every one..i got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run a java program