Home Discussion Discuss: Java ClassPath

  • path for you can run java any where you feel hapythulasiram May 27, 2011 at 12:59 PM

    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) { System.out.println("Hello, World!"); } } 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. C:\mywork> dir 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... C:\mywork> dir 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: Hello, World! 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 ;C:\Program Files\Java\jdk1.5.0_09\bin (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.

  • CLASSPATHPAVAN May 31, 2011 at 7:38 AM

    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

  • GreatAdvernus July 2, 2011 at 8:40 AM

    Very nice tutorial

  • jangaiahjangaiah July 4, 2011 at 10:38 PM

    i want know about java

  • javasonu July 29, 2011 at 12:03 AM

    sir whan 1 pakage in another folder and another pakage is cantain in another folder.then how we set the pat

  • haikishore September 14, 2011 at 8:05 PM

    how to set classpath of jdk6

  • difficulty in setting of path of java.prabhat ranjan December 25, 2011 at 2:43 AM

    Hi 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.

  • unable to execute jar command vinayaka D J January 9, 2012 at 11:19 PM

    i am trying to execute jar command but its showing command not found what to do

  • hideepika March 3, 2012 at 6:34 PM

    i am getting noclassfound error while runtime

  • javamadhavi June 29, 2012 at 7:22 PM

    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

  • sYQaUsZUhBRjMzNejla September 28, 2012 at 5:59 AM

    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.

  • Java Class pathThiru July 31, 2013 at 10:26 AM

    Its very simple and Working fine .. Thanks

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Related Articles
Java Beginners

variable. That tells the Java Virtual Machine where to look for user-defined classes and packages when running Java programs.   Hi Friend, Classpath...CLasspath  what is classpath?   The <B>Classpath 

Java Beginners

CLasspath  what is classpath?   Hello, 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 

Java Interview Questions

Java classpath
Java classpath  What is the difference between classpath and path variable 

Java Beginners

path classpath
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 Thanks 

Java Technology Tutorials

Java ClassPath
Java ClassPath      ... numerous directories and JAR archives. The -classpath option to javac and java.... i.e.classpath  C:\Java\jdk1.6.0_03\lib For setting CLASSPATH using 

Struts Questions


Java Beginners

Classpath - Java Beginners
Java classpath setting command line  Is there any command line to set the classpath in Java 

JDBC Questions

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 

Struts Questions

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 Beginners

running java with classpath in cygwin
running java with classpath in cygwin  The following command works in cmd.exe but failts in cygwin shell. java -cp .;oracle.jar;mysql.jar Executecmd query value; how should i alter the command to run in the bash shell?thanks 

Java Beginners

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). but i 

Java Beginners

What is difference between Path and Classpath?
What is difference between Path and Classpath?   hi What is difference between Path and Classpath? thanks   Hi, The Path & Classpath are used for operating system level environment variales. We mostly use Path 

Java Beginners

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 C:\Program Files 

Java Beginners

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 

Java Beginners

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 

Eclipse Plugins

ClassPath Helper
ClassPath Helper       Every developer who has used Java is familiar with the classpath. Usually it doesn't take long to generate your first 

JSP Servlet Questions

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 


Class path
: java -classpath D:\Application org.roseindia.MyApp where -classpath.... set CLASSPATH=D:\myprogram java org.roseindia.MyApp Setting... given below:  java -classpath D:\Application; D:\Application 

Programming Tutorials

Topic 7: Fundamentals

Java Beginners

java  why to set classpath in java 

Java Beginners

java  why to set classpath in java 

Java Beginners

java  why to set classpath in java 

Java Beginners

java  why to set classpath in java 

Java Beginners

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 

JavaScript Questions

java  what is classpath?describe various levels of access protection 

Java Interview Questions

java question
java question  what is the difference between path and classpath in java 

Java Beginners

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. Thanks 

JSP Servlet Questions

Query  how can i set path and Classpath or Environmental Variable for jsp/servlet program to compile and run 

Hibernate Questions

hibernate  hi what are the necessary jar files that we need to set in the classpath to execute a hibernate application 

Java Beginners

JDBC  how to set classpath for eclipse, java, where to copy jdbc connector