Running a Java Program from Command Prompt
Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text:
public class HelloWorld
public static void main(String args)
Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.
Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt...
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:
If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!
It is possible to make the path setting permanent but you have to be very careful because your system might crash if you make a mistake. Proceed with extreme caution!
In Windows XP, go to Control Panel, choose "System," click on the "Advanced" tab, click on the "Environment variables" button. In the lower list, "System variables," click on Path:
Click "Edit" and at the end append
(or the path to the appropriate folder where the latest version of JDK is installed). Do not put spaces before the appended path string.
Click OK on the path edit box and OK on the Ennvironment Variables box. The new setting will go into effect next time you run Command Prompt.
I'm using Windows7 i created classpath for java ....But when i try to execute java program it showing classnotfound exception........ When i remove classpath from computer then program runs fine........I tried all possible ways to keep classpath but i doesnt work for me......I cant do JDBC prog's without setting classpath so pls help me
sir, i am unable to set my java class path please help me
Very nice tutorial
i want know about java
sir whan 1 pakage in another folder and another pakage is cantain in another folder.then how we set the pat
I have window7 operating system.and i have installed
jdk-7u2-windows-x64.exe for java program.
But i have a problem to set path of java.
and also how to run java program.
i am trying to execute jar command but its showing command not found what to do
Thanks to this services for java.
Hello Sir I'm Pradeep Patel facing problem to set path and classpath for java programs
i am getting noclassfound error while runtime
I have set the path and classpath in environment variables.eventhough iam getting the error like
javac:file not found:Demo.java
usage java:<options> <source files>
please rectify my mistake if any
My problem is the recoruse file is available in one context (say aa), I'm trying to load the same using ResourceBundle from another context (say bb). But always I get MissingResourceException exception. But it works well when I put the properties file under bb context I think I can use the solution that you mentioned in this post for the time being. But I'm searching for a solution so that I can use ResourceBundle(since the property file is for i18n purposes). Any way thanks dude it is indeed a good post.
two different folder having same package and same class name
Post your Comment
That tells the Java Virtual Machine where to look for user-defined classes and packages when running Java programs.
Classpath...CLasspath what is classpath?
CLasspath what is classpath?
Classpath is Environment Variable that tells JVM or Java Tools where to find the classes. In CLASSPATH environment you need to specify only .class files (i.e., jar, zip files
CLASSPATH tells Java where to search for programs
Where to look... the environment variable
CLASSPATH, which Java uses to see where it should find Java programs... complete explanation of CLASSPATH can be found in
Java Glossary : classpath
Java classpath What is the difference between classpath and path variable
be in path.
While Classpath is Enviroment Variable that tells JVM or Java Tools where...path classpath EXPLAIN PATH AND CLASSPATH ? DIFF
send me ans plz...://www.roseindia.net/java/java-classpath.shtml
... archives. The -classpath
option to javac and java allows multiple
For setting CLASSPATH using command
STRUCT CLASSPATH - Struts
STRUCT CLASSPATH What is the STRUCT CLASSPATH
Classpath - Java Beginners
Java classpath setting command line Is there any command line to set the classpath in Java
Installing the Driver and Configuring the CLASSPATH
Installing the Driver and Configuring the CLASSPATH What is the procedure to Installing the Driver and Configuring the CLASSPATH mysql jdbc connector? the jar file
classpath and path for structs1.3.8
classpath and path for structs1.3.8 How to set classpath and path for structs1.3.8 ?
just add struts-core-1.3.8.jar file to CLASSPATH or ext folder of jdk installation(\jre\lib\ext folder) and add 10 jar files(main
JAVA CLASSPATH PROBLEM
JAVA CLASSPATH PROBLEM hi all Friends
I am stuck using the java servlets and problem raise for classpath.
I had a problem with servlet to call... that it didn't found any java class (which is java class calling from servlet).
What is difference between Path and Classpath?
What is difference between Path and Classpath? hi
What is difference between Path and Classpath?
The Path & Classpath are used for operating system level environment variales. We mostly use Path
Checking Classpath Validity - Java Tutorials
Checking Classpath Validity
2001-12-13 The Java Specialists' Newsletter [Issue 037] - Checking that your classpath is valid
Sydney Redelinghuys... to be -classpath.
setting classpath of tomcat - Java Beginners
setting classpath of tomcat hello i am giri.
I Installed the Tomcat6 in my system and the problem is, How to set the classpath, Please give...;System->Environment Variables->
and set the CLASSPATH
java classpath prbm in windows 7
java classpath prbm in windows 7 i have a problem to set the classpath in windows7
in my system oracle is not there.
environment variables under that
user variables i set them like this:
CLASS .;C:\Program Files\Java\jdk1.6.0_32
getting an error when set classpath
getting an error when set classpath Hello Everyone! i have used hssf model for reading excel sheet in my project & i have set classpath for that jar file but when i compile the program it will compile correctly but when i
Every developer who has used Java is familiar with the
classpath. Usually it doesn't take long to generate your first
Set classpath and "commons-fileupload.jar" - JSP-Servlet
Set classpath and "commons-fileupload.jar" Hi,
Thanks for the quick reply to my question on "Java compilation error".. As you said, i have...)..where should i place it, and also confuse at the setting classpath, please guide
java -classpath D:\Application org.roseindia.MyApp
java -classpath D:\Application;
Topic 7: Fundamentals
java why to set classpath in java
path - Java Beginners
meaning of path and classpath what is the meaning of path and classpath. How it is set in environment variable. Path and ClassPath in in JAVAJava ClassPath Resources:-http://www.roseindia.net/java/java-classpath.shtml
java - Java Beginners
java why we use classpath.? Hi Friend,
We used classpath to tell the Java Virtual Machine about the location of user-defined classes and packages in Java programs.
JDBC how to set classpath for eclipse, java, where to copy jdbc connector
what are the necessary jar files that we need to set in the classpath to execute a hibernate application
Query how can i set path and Classpath or Environmental Variable for jsp/servlet program to compile and run
Hi... - Struts
write the classpath and send classpath command Hi,
you set path = C:\j2sdk1.5\bin;