Classpath variable

Can someone please help me with what exactly the classpath variable does? I have my java and javac.exe files located in C:\Program Files\Java\jdk1.5.0\bin. I can only compile and run files that are located in this directory. So if I put my HelloWorld.java file in that directory and run the compiler, it does create a HelloWorld.class file in that directory too. When I run the file using java HelloWorld the program runs fine.
How can I save the files in other directories but still compile and run them? Any help would be great.
Thanks.

classpath variable is where u specify a path with files and such in it.
Ie \Java\jdk1.5.0\bin has got files like javac.exe and such which can normally only be run from that folder but if u specify that folder as a classpath variable it means that u can run the file javac.exe from anywhere in the computer.
To do this I have created a batch file I run every time.
part of it is:
set JAVA_HOME=C:\j2sdk1.4.2_05
(no need to specify the bin folder I think)
if u have something like XP look at system in the control panel under a button called environmental variables and add in that path
Regards, Rory

Similar Messages

  • Novice Trying to Set The CLASSPATH Variable

    I am trying to compile a file (which can be downloaded at http://java.sun.com/docs/books/tutorial/getStarted/QandE/FirstClass.java). Despite being able to successfully compile several other files, this particular one will not compile. According to my JAVA Tutorial book, the problem may lie in the CLASSPATH variable, but I am having a great deal of trouble trying to set/understand it. My operating system is WINDOWS 2000. PLEASE HELP!!!

    in win 2000, the classpath can be set by the following process.
    Right Click My Computer icon and click on properties.
    (This can be done by going to the Control Panel and Double Clicking the System icon too).
    Once you have the properties window of the system click on the 'Advanced' tab.
    There is a button called 'Environment variables'.Click on it.
    You will have a part called 'System Variables' there.
    Here there is an entry called Classpath. Just add the entry of what you want to add to the classpath, separating each entry with a ';' semicolon as mentioned there and click on the Set button.
    That should set the classpath.If that does not take effect immediately, restart the system and it will take effect.
    Tell me if it worx.
    All the best. Bye!
    Cheers,
    Win!

  • How can i figuere out my classpath variable

    the tutorial is saying that i need to create and appropriate class path. i know wer to go to set it but what should i set it to. if that makes any sense. you see im trying to run the hello world program and ive tryed everything but setting the classpath variable so that the os will know were to go to look for the information but i dont really know what state the path is in and i dont know what to set it to. id greatly appreciate the support.

    Open a Command Prompt window and type "echo %CLASSPATH%" on windows or "echo $CLASSPATH" on unix.
    That will show you your existing CLASSPATH.
    Mine looks like this:
    .;C:\program files\j2sdk1.4.2_02\jre\lib\rt.jar
    The Classpath contains all the jars and class folders that your program needs separated by ; (windows) and : (unix). So if your classes are in the folder: myapp\classes, then add
    ;myapp\classes
    to the end of your classpath.

  • Unsure about Classpath variable

    What should the classpath variable be set to? I am working through a tutorial from the command line for the first time and running into problems with classdefnotfound errors. It's saying to run it using java -classpath, but I thought that was just a shorter way to say what folder your workspace files are in. What should this be set to?

    The environment variable CLASSPATH should not be set to anything. It should not exist.
    If you do not include a -cp (or -classpath) command-line option, then the system looks for a CLASSPATH environment variable. If it finds it, it acts the same as if you had used that for the -classpath command-line option. If it does not, then it by default acts as if you included the "current directory" only as the -classpath.
    If you do include a -cp / -classpath command-line option, then the system ignores any CLASSPATH environment variable anyway.
    All "real" systems do not rely on a CLASSPATH environment variable. IDEs don't use it; J2EE containers (weblogic, jboss, etc) don't use it; applets don't use it; etc etc etc. It's basically only there for "toy" applications and beginners to try and make their life a little easier. However it just turns out to have confused them even more.

  • CLASSPATH variable problem

    I have downloaded the Java 3D API but the compiler keeps telling me off for the java 3d packages not existing. How can I make it understand where the packages are and how to access them?
    Thanks Rufus,

    you must set the CLASSPATH variable to point to the java3d api jar files. Install the java3d to a jdk, then set the class path to include these jar files, go to the command line and type:
    C:\>SET CLASSPATH=%CLASSPATH%;c:\jdk1.3.0_02\jre\lib\ext\j3daudio.jar;c:\jdk1.3.0_02\jre\lib\ext\j3dcore.jar;c:\jdk1.3.0_02\jre\lib\ext\j3dutils.jar;c:\jdk1.3.0_02\jre\lib\ext\vecmath.jar
    *Assuming that the c:\jdk1.3.0_02\jre\lib\ext is the path to the java3d jars.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help me !! how do i configure the CLASSPATH variable in windows xp??

    I've just downloaded the new java envirolment platform 1.4
    but i don't know what to I have to write in my CLASSPATH variable
    in windows xp
    with my previous version (1.3) the variable was:
    CLASSPATH value=d:\java\j2re1.3.1\lib\tools.jar
    with this new version I don't see any tools.jar file in my java directory ;
    what to I have to to ??
    another thing:
    do the "javac" command works with the new version of the platform ??
    thanks to anyone who will answer

    does it have a autoexec.bat? It chould go in there.

  • Why did eclipse add a CLASSPATH variable to my system?

    After recently installing eclipse I discovered that while I can still compile normally I was getting NoClassDefFoundError running java from my command prompt.
    After some puzzlement and wondering if I had gone crazy I noticed the new environment variable CLASSPATH.
    Two questions.
    1) Why?
    2) Can I get rid of it safely or will that give eclipse upset?

    I recently installed two things. Eclipse andiTunes
    (but only because I
    wanted QuickTime). So I guess it was iTunes. Howvery bizarre.
    Just out of curiosity: what was the value of that
    CLASSPATH variable?
    kind regards,
    JosUmm I already deleted it but it was pointing to
    something javaish. I think something in the lib/extActually I still had a command window open and env said this
    CLASSPATH=C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip

  • Setting my Classpath variable

    Hi
    Could someone please help me get the classpath variable working
    C:\Java\sampledir\Java Game Programming;.;C:\Program Files\s1studio_jdk\j2sdk1.4.1_02\lib\tools.jar
    This is what I have in the Classpath variable now in my Windows 2000 O/S
    Now from what I gather with having this set up in the classpath I should be able to compile anything in the Java Game Programming Folder and I can do it right from the C:\ prompt. Am I correct in thinking this?? or do I need to be in the directory with the file I want to compile??
    The error message I recieve after typing from the C:\ prompt javac GameOver.java
    produces this error message
    error: cannot read: GameOver.java
    1 error
    Now I do know everything within the file is correct because it compiles and runs successfully in Sun One Studio. :)
    Thank you
    Scott

    The classpath is a way for the compiler to resolve class names it encounters in the source files.
    But you still have to give it the exact path to your source file !
    you don't need to be in the directory of the file, you can just give its absolute path from whatever directory you happen to be.

  • Help with CLASSPATH variable please

    Hi everyone!!
    Please, help to set up my classpath variable. I know I know I have guidelines in API but I don't achieve it, I'm so clumsy.
    I've formated my hard disk and installed everything again, but the classpath is wrong because I can't compile my java files.
    I've tried with this:
    C:\Program Files\Java\jdk1.5.0_06\scr.zip;C:\Program Files\Java\jdk1.5.0_06\javac.exe;C:\Program Files\Java\jdk1.5.0_06\java.exe
    I've also tried with the same lines but unnaming files (finishing with '\')
    What am I doing wrong?
    Thank you very much for your attention and help.
    Merry Christmas and Happy New Year!!
    And I hope the Three Wise Men bring you everything!!

    Please post your exact problem and the exact error message. I think you are having a problem compiling, but I am not sure. What is not working? What is the error?
    You posted a path, but if that is your Classpath, you should not have javac or java in the Classpath.

  • Jgrasp classpath variable

    well here is the deal, i am using JGrasp to compile and excecute my programs, i set the PATH variable and the CLASSPATH variable to the appropriate directories. but still i get the following error message when i run JGrasp:
    "Unable to initialize threads: cannot find class java/lang/Thread"
    i think that is because jgrasp is still not using the correct CLASSPATH that i set. when i looked at the JGrasp control shell i found the following startup command:
    "C:\JDK1.1.6\BIN\java.exe" -classpath "jgrasp.jar" Grasp -i -j "C:\JDK1.1.6\BIN" -s "C:\My Documents" -e "C:\jGRASP_extensions"
    i think that is the problem, since jgrasp change the classpath variable to "jgrasp.jar" when it is started. does anybody has any clue on how to fix this? thx

    http://www.eng.auburn.edu/department/cse/research/grasp/jgrasp/main.htm
    Quote below is from right at start of the above link. Also includes instructions on setup, installation and running same.
    Should tell you what you need to know.
    Important Notes
    This is jGRASP version 1.5.3 Beta 2. Check http://www.eng.auburn.edu/grasp/ for the latest version of jGRASP.
    jGRASP is written in Java. Java 1.2 or higher must be installed on your machine in order to run jGRASP. The full JDK 1.3 or higher (not the JRE) from Sun is required in order to use the integrated Java debugger.
    jGRASP does not include any compilers. The JRE bundled version and all other versions of jGRASP do not include a Java compiler. In order to compile programs you must have a compiler installed.
    Which JVM to Use
    If you have downloaded a JRE bundled version of jGRASP, this is not a concern. Otherwise, Sun JDK 1.4 is suggested. When jGRASP starts, you may get a message telling you that jGRASP has known problems or minor problems, or has not been tested on your system.
    To use the integrated Java debugger, JDK 1.3 or higher is needed (and you should develop under 1.3 or higher also).

  • Check your CLASSPATH variable.....

    I 'm trying to run the demo (Linux envinroment) and I get this error though Classpath is set...
    see the display below >>>
    lando@lando-desktop:~/DERBYTUTOR$ echo $CLASSPATH
    :/home/lando/jdk1.6.0_11/db/lib/*.jar
    lando@lando-desktop:~/DERBYTUTOR$ java WwdEmbedded
    ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
    >>> Please check your CLASSPATH variable <<<
    . . . exception thrown:
    ---SQLException Caught---
    SQLState: 08001
    Severity: 0
    Message: No suitable driver found for jdbc:derby:jdbcDemoDB;create=true
    java.sql.SQLException: No suitable driver found for jdbc:derby:jdbcDemoDB;create=true
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:207)
    at WwdEmbedded.main(WwdEmbedded.java:72)
    Getting Started With Derby JDBC program ending.
    Where is the problem ?
    Thanks a lot.
    Edited by: lndo on Feb 5, 2009 11:33 AM

    Classpath setting in .bashrc is below ...and is correct
    export CLASSPATH=$DERBY_HOME/lib/*.jar:.;
    and I can disply it >>>
    lando@lando-desktop:~$ echo $CLASSPATH
    :/home/lando/jdk1.6.0_11/db/lib/*.jar:.
    and its containt is here >>>
    lando@lando-desktop:~/jdk1.6.0_11/db/lib$ ls
    derbyclient.jar        derbyLocale_it.jar     derbyLocale_zh_TW.jar
    derby.jar              derbyLocale_ja_JP.jar  derbynet.jar
    derbyLocale_cs.jar     derbyLocale_ko_KR.jar  derbyrun.jar
    derbyLocale_de_DE.jar  derbyLocale_pl.jar     derbytools.jar
    derbyLocale_es.jar     derbyLocale_pt_BR.jar  derby.war
    derbyLocale_fr.jar     derbyLocale_ru.jar
    derbyLocale_hu.jar     derbyLocale_zh_CN.jarbut if before launching the program I type in command line >
    CLASSPATH=$DERBY_HOME/lib/derby.jar:.;
    It works fine ....as if /db/lib/*.jar:. could not get derby.jar !

  • Can't Edit ECLIPSE_HOME Classpath Variable

    Hi,
    I am trying to edit ECLIPSE_HOME Classpath Variable, which i can do as long as Dev Studio is open. If I close NWDS and re-open it, the change to the variable is lost. Any ideas?
    Thank-you,
    -Kevin

    Kind of a drastic step to take as this is basically starting from scratch, but it does work. I was hoping there was a way to access where these variables are stored to modify it, but no such luck.
    Thanks,
    -Kevin

  • NWDS - Unbound classpath variable  PORTALAPPS / SAP_SERVER_BIN / SAPSERVERB

    Hi there,
    i have a problem. i am new to the NWDS... i have a project here and i know what i have to change... then export it to PAR and import it to the portal.. thats all not the problem.. but i`ve never worked with the NWDS...
    After i imported the Project the NWDS comes with the following error message:
    Description
    The project was not built due to classpath errors (incomplete or involved in cycle).
    Unbound classpath variable: 'PORTALAPPS/lib/aliases.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/lib/prtapi.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.netweaver.bc.rf/lib/bc.rf.framework_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.netweaver.bc.rf.service/lib/bc.rf.global.service.urlgenerator_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.netweaver.bc.sf/lib/bc.sf.framework_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.netweaver.bc.util/lib/bc.util.public_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.portal.navigation.AliasService/lib/com.sap.portal.navigation.AliasService_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.portal.navigation.api_service/lib/com.sap.portal.navigation.api_service_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.portal.navigation.helperservice/lib/com.sap.portal.navigation.helperservice_api.jar'.
    Unbound classpath variable: 'PORTALAPPS/portal/portalapps/com.sap.portal.usermanagement/lib/com.sap.security.api.ep5.jar'.
    Unbound classpath variable: 'SAP_SERVER_BIN/ext/tckmcbc.uwl~api/bc.uwl.service.api_api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/com.sap.security.api.sda/com.sap.security.api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/servlet/servlet.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/webservices_lib/jaxrpc-api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/webservices_lib/webservices_lib.jar'.
    So my NWDS runs on my Local Windows Client.. Our Portals are on Linux Machines
    What do i have to do know?
    I searched the whole SDN and google.. but found nothing... Hope someone can help here?
    Regards

    OK.. i found the whole PORTALAPPS JAR Files... but i cannot find the JAR Files from SAP_SERVER_BIN and SAPSERVERBIN
    Unbound classpath variable: 'SAP_SERVER_BIN/ext/tckmcbc.uwl~api/bc.uwl.service.api_api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/com.sap.security.api.sda/com.sap.security.api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/servlet/servlet.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/webservices_lib/jaxrpc-api.jar'.
    Unbound classpath variable: 'SAPSERVERBIN/ext/webservices_lib/webservices_lib.jar'.
    Where in the Browse Deployment can i find them?
    Or can someone send me the files with e-mail?
    Regards
    Bjoern
    Edited by: Bjoern Bayerschmidt on Nov 2, 2010 9:05 AM

  • Setting Up CLASSPATH variable

    Dears,
    In PI 7.1 we are getting one error:
    We are getting an u201CSAPClassNotFoundException:u201D. The reason for this is as I got we need to set the classpath in the PI Server.
    Please do as below:
    The following is an example of the CLASSPATH statement that is used for a Unix/Linux application:
    CLASSPATH =.:/home/usr1/mssqlserverjdbc/Driver/sqljdbc_2.0/enu/sqljdbc.jar
    Please suggest how can I set this path on AIX ,Is it a env variable.If yes then as I am getting aftre setting ones and logging out this variable will get dissaper.
    So please suggest how can i set this path.
    SHivam

    Hi,
    Where you are facing problem?? r u facing problem when you using JDBC Communication Chanels??
    Regards,
    Raj

  • Classpath variable and WinXP

    I can't get the javac compiler for jdk1.2 to recognize the classpath I set in the autoexec.bat file.
    here's the line, I've also tried setenv.. Anyone have an answer?
    set CLASSPATH = .;c:\jdk1.2\classes

    To silverdream:
    There are 2 variables that affect Java, PATH and CLASSPATH. You set them there.
    The Path is a set of pointers that Windows uses to locate programs that you execute, like javac.exe and java.exe. This setting is explained here:
    http://java.sun.com/j2se/1.4/install-windows.html
    Scroll down to: 5. Update the PATH variable
    The CLASSPATH is another set of pointers that is used by Java to find the files that you create and want compiled and/or run. This setting is explained here:
    Setting the Classpath:
    http://java.sun.com/j2se/1.4/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means [i]the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html
    Examples:
    This is my path
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BATCH;C:\J2SDK1.4.0_01\BIN;C:\PROGRA~1\UTILIT~1;C:\PROGRA~1\WIN98RK
    This is my classpath
    CLASSPATH=.;C:\mjava;C:\mnrx;C:\NetRexx\lib\NetRexxC.jar;C:\j2sdk1.4.0_1\lib\to
    ols.jar;C:\NetRexx\NrxRedBk

Maybe you are looking for