Setting CLASSPATH and PATH properly how?

I have set PATH=c:\jdk_install_directory\bin which works fine. However, for example when I create an app or small program for example, simply to print out a line on the screen, it works when I compile in NetBeans. However, if I copy the java file to another directory, my C: root for example, I can compile it, but when I run the class file it gives me errors saying it can't find certain classes. So, I figure its something with the classpath variable that I have to fix. How can I do this properly for both J2SE and J2EE using default install directories for each.
Thanks so much!!

Your PATH is exactly what it should be.
The CLASSPATH answer depends on where you're compiling and running.
If you're doing things on the command line, I think the right answer is to use the -classpath option on javac.exe and java.exe.
If you're using NetBeans or another IDE, the right answer is to add JARs and paths according to the idiom demanded by the IDE. Each one is different, and all the ones I know of ignore the system CLASSPATH environment variable. I don't have one set on my machine.

Similar Messages

  • Setting Classpath and Path on Windows ME

    Hi..How do I set up the classpath and path on windows ME. Do I use DOS or run the autoexec.bat from windows directly. I have jdk1.3.1 abd my classpath and path are:
    set classpath="C:\jdk1.3.1\bin"
    set PATH=C:\windows\xxxx\;C:\jdk1.3.1\bin
    I sometimes can't compile my programs from other directories other than jdk1.3.1\bin. Why? Is there a way I can compile my program just from the C:\ directory like:
    C:\javac myprogram.java
    C:\java myprogram
    Thanks.

    If you put . in the beginning of your classpath, java always searches the folder you are currently in.
    Now to set the classpath try clicking from the startmenu:
    settings/control panel/system. Then click advanced tab and then the Enviroment variables. I'm on win2000 but I think it should be the same on ME.
    Make sure it starts with .;C:\jdk1.3.1\bin;....
    I think installing jdk puts in the essentials, but if you have certain folders you store your classes in you can stick those in there as well.
    If you hava more questions about this, I suggest searching these forums on Keywords like : "set CLASSPATH PATH". Then you'll find a bunch of threads solving this problem.
    Sjur

  • Problem in setting CLASSPATH and PATH

    I am a newbie in java. I downloaded and run the "j2eesdk-1_4_01-windows.exe" from Internet. By default, it creates a new user variable, which is "PATH = C:\Sun\AppServer\bin". My problem is when I try to compile a java, I get an error message, which is
    'javac' is not recognized as an internal or external command,
    operable program or batch file.
    I create a new user variable which is "CLASSPATH = .;C:\Sun\AppServer\jdk\bin"
    and add new variable into my system variable, which is
    "PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Sun\AppServer\jdk\lib"
    However, it doesn't work and give the same error message. Any idea about the solution?
    Thanks in advanced.

    Your PATH variable needs to include the path to the J2SE SDK bin directory. It looks like you added it to your CLASSPATH instead

  • Problems in Classpath and Path 's variables setting in Windows XP

    Here is my drive structure in my PC:
    1. hard drive (primary slave, Partition: C and E where E boot Windows XP
    2. Hard drive 2 (Primary Master), Drive letter: D
    Although my default boot directory is E (for strange reason, i like to keep
    that way for now), I installed other programs in C and D drive dues drive
    space factors.
    So My java sdk1.4.2_02 has been installed in C:\Java_home directory, the
    following is my Classpath and Path values:
    (CLASSPATH Variables)
    Classpath=.;
    c:\java_home\j2sdk1.4.2_02;
    e:\Program Files\java\j2re1.4.2_02;c:\java_home; c:\java_home\j2sdk1.4.2_01
    \lib;e:\Program Files\java; e:\Program Files\java web start;c:\java_home\j2
    sdk1.4.2_02\jre\lib;c:\java_home\java\petstore1.3.2\src\lib\jst1;
    (PATH variables)
    c:\java_home\j2sdk1.4.2_01\bin;C:\java_home;e:\Pr
    ogram Files\java;c:\java_home\jdk1.4.2_2\bin;E:\Program Files\Oracle\jre\1.
    1.8\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\system32\WBEM;E:\
    Program Files\Support Tools\;
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    Path=D:\oracle\ora92\bin;E:\Program Files\Oracle\jre\1.3.1\bin;
    My Fruit txt and Fruit.java file is located in my c:\java_home folder
    when I try to compile the my file as <c:\java_home\javadoc Fruit.java), it
    gives me the error message<'javac' is not recognized as an internal or
    external command,operable program or batch file.>
    however, I can compile the Fruit file from C:\java_home\jdk1.4.2_2
    \bin\javadoc Fruit.java; with out any problem of course I have to copy the
    Fruit.java file at the C:\java_home\jdk1.4.2_2\bin\javadoc Fruit.java
    folder.
    I am requesting u please help or advise me to correct my mistakes
    Ely
    [email protected]

    I must confess that I am totally unable to understand what your PATH is set to. The error that you see,
    <'javac' is not recognized as an internal or external command,operable program or batch file.>
    is due to a missing or incorrectly set PATH. It is used by Windows to find executable file (like javac.exe) that you have added to the computer. Item #5 on this page gives you instructions on how to set it: http://java.sun.com/j2se/1.4.2/install-windows.html
    As for the setting of the CLASSPATH, you seem to have a number of different versions of java (1.4.2_02, 1.4.2_01, 1.4.2_2, and 1.1.8) and I doubt that these are all valid. You are also using an unusual syntax C:\java_home\jdk1.4.2_2\bin\javadoc Fruit.java and I wonder if that is really C:\java_home\jdk1.4.2_2\bin\javadoc\Fruit.java? I think the best action is to point you to Sun's instructions and information about setting and using the CLASSPATH.
    The CLASSPATH is a set of pointers that is used by Java to find the files that YOU (not Java) create and want compiled and/or run.
    Setting the Classpath:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html
    Examples:
    This is my path
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BATCH;C:\J2SDK1.4.2_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.2_01\lib\tools.jar;C:\NetRexx\NrxRedBk

  • How to set classpath and server configuration in eclipse

    i am new to eclipse tool pls anyone tell me to set classpath and serverconfiguration (tomcat) and sample program

    Get WTP [1], install it [2] and checkout one of the lot Eclipse WTP tutorials [3].
    [1] http://www.eclipse.org/webtools/
    [2] http://ftp.osuosl.org/pub/eclipse/technology/phoenix/demos/install-wtp/install-wtp.html
    [3] http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html

  • Setting classpath and library path...

    hello..
    i have downloaded the jfreechart1.0.4 for adding chart in my java application...though i have gone through the installation guide...but i havent figured it out how to make the packages available to my java application....
    i am very new to java ....so pls suggest me any way to make those packages available to my java which is in my j2sdk\bin folder...and truly i dont have any idea where to set the lib path and class path....so pls post any suggestion or any url that will help me...

    Hi,
    You should not place files in the bin directory of your JDK/JRE. Just place the jar-files somewhere close to your application, e.g. in a lib folder in your project folder. Then set the classpath to point to those jars when you execute your application.
    E.g.
    java -classpath ./classes/;./lib/somejar.jar;./lib/anotherjar.jar MainClassKaj

  • Classpath and path of jdkjdk-1_5_0_09

    hi
    i have installed c:\progrmaefiles\java\ jdk-1_5_0_09 on my pc but i m not able set systemenvironment variable like PATH and CLASSPATH .i tried lot of option but it does not work so plz anyone help me out.i m using windows Xp operating system. when i m running any java programe i m getting error " Exception in thread "main" java.lang.NoClass.DefFoundError.plz hep me out.
    thx manu

    That's CLASSPATH, not PATH.
    Without seeing your exact directory structure and the exact command you're runing, nobody can give you specific advice. Here are some explanations of how it works, though.
    Javapedia: Classpath
    How Classes are Found
    Setting the class path (Windows)
    Setting the class path (Solaris/Linux)
    Understanding the Java ClassLoader
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • Set CLASSPATH does not work, how do I run java.exe?

    Hi guys,
    I have a problem running the java.exe and I'm using Win XP. Here is my problem:
    Under the command prompt, I set the path: path = C:\Program Files\Java 2\j2sdk1.4.2_05\bin
    Then I created a folder in E:\Hello. I save my Hello.java in that folder, and I compiled it:
    javac Hello.java
    Now, there is a Hello.class created in that folder.
    Then I try to run it: java Hello
    but I got an error: "Exception in thread "main" java.lang.NoClassDefFoundError: Hello"
    So, I try to set CLASSPATH, however, the problem remains, no matter how hard I try.
    Any ideas?

    None of the suggestion worked, I wonder why???
    Here is my location for the JDK:
    C:\Program Files\Java 2\j2sdk1.4.2_05\bin
    Here is my location for my Java project file:
    E:\JavaProject\Hello
    Here is the file name:
    Hello.java
    Here is the command prompt:
    C:\Documents and Settings\Alex Ngai> e:
    E:\> cd JavaProject
    E:\JavaProject> cd Hello
    E:\JavaProject\Hello> path = C:\Program Files\Java
    2\j2sdk1.4.2_05\bin
    E:\JavaProject\Hello> javac Hello.java
    E:\JavaProject\Hello> java Hello
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Hello
    E:\JavaProject\Hello> java -cp Hello
    // Does not work, it lists all of the options for java
    E:\JavaProject\Hello> set CLASSPATH =
    E:\JavaProject\Hello
    CLASSPATH="C:\Program
    Files\Java\j2re1.4.2_04\lib\ext\QTJava.zip"
    E:\JavaProject\Hello> java Hello
    Exception in thread "main"
    java.lang.NoClassDefFoundError: Hello
    // I have tried a lot more, none of them won't work!!
    Now what should I try in the following command prompt?
    E:\JavaProject\Hello>Given the above there is only one possible explaination.
    You have a file named "Hello.java".
    In that file you have a non-public class which is NOT named "Hello". Instead it is named something like "HelloWorld" or even "hello" (case matters.)

  • Setting classpath and creating packages

    Hi
    I am new to Java and my questions are basic.
    1)I am using the kawa IDE and i dont know how to create and use packages.
    2)Creating classpath to compile and run java programs from the Dos prompt.
    I would appreciate any help on these questions

    I'm not sure how to use KAWA.
    When it comes to classpaths, though, I would recommend not setting it as an environment variable - this tends to cause confusion if you work on more than one project at a time on your machine. Either set it locally or specify it directly on the command line.
    Often it's a good idea to write a batch file for compiling and executing your code:
    setlocal
    set PATH=c:\j2sdk-1.3
    set CLASSPATH=c:\jars\Servlet.jar
    javac MyClass.java
    endlocalHope this helps.

  • How to set the classpath and path from the jsp to call  java class function

    Hi Exprets,
    I have a requirement to call a java class function which returns a hashmap object from the jsp. The java class in present in one jar file and that jar file is location somewhere in unix path. So the requirement is to set the classpath for that jar file and then create the object of the java class and then call the function.
    If any one know how to achieve it, please reply as soon as possible.
    thanks in advance,
    swapna soni.

    It is never advisable to store large data sets in the session. But it will depend on a lot of factors:
    1. How costly is the query retrieving the data from the database?
    If it's a complex query with lots of joins and stuff, then it will be better to store it in the session as processing the query each time will take a lot of time and will decrease performance. On the other hand if the query is simple then it's advisable not to store it in the session, and fetch it each time.
    2. Are there chances for the data to become stale within a session?
    In this case storing the data is session will mean holding the stale data till the user session lasts which is not right.
    3. How many data sets does the session already holds?
    If there are large no. of data sets already present in the session, then it's strictly not advisable to store the data in the session.
    4. Does the server employ some kind of caching mechanism?
    Using session cache can definitely improve performance.
    You will have to figure out, what is the best way analyzing all the factors and which would be best in the situation. As per my knowledge, session is the only place where session specific data can be stored.
    Also, another thing, if the data set retrieved is some kind of data to be displayed in reports, then it would be better to use a pagination query, which will retrieve only the specific no. of rows at a time. A navigation provided in the UI will retrieve the next/previous data set to display.
    Thanks,
    Shakti

  • Post jDev 903 cleanup: Classpath and Path.

    Having installed the new [complete set] 9.0.3 and having decided NOT use 9.0.2 or other developer suite tools, it's time to clean up my path and classpath settings.
    Please help me sort it all out. Thanks.
    Per instructions I did not install the new 9.0.3 into any existing oracle_home. The home_dir for the 9.0.2 and complete suite is: E:\Programs\OraDevSuite.
    My Classpath has three entries: (formatted for easy reading on the forum.)
    CLASSPATH=
    E:\Programs\OraDevSuite\jlib\bigraphbean.jar;
    E:\Programs\OraDevSuite\jlib\LW_PfjBean.jar;
    E:\Programs\OraDevSuite\jlib\bigraphbean-nls.zip
    Questions: 1. Can (Should) I throw these out? 2. Do I need anything else in the classpath? (The java command line uses the -classpath parameter anyhow.)
    Here are the PATH settings (in the order maintained by the os). This really needs to be cleaned up. I have added my question on each line. Sounds like alot of questions but many are the same type.
    Path=
    E:\Programs\OraDevSuite\bin; (Old suite: Good-bye?)
    E:\Programs\OraDevSuite\jdk\jre\bin; (Old suite: Good-bye?)
    E:\Programs\OraDevSuite\jdk\jre\bin\classic; (Old suite: Good-bye?)
    E:\Programs\OraDevSuite\jdk\jre\bin\classic; (Old suite: Good-bye?)
    E:\Programs\OraDevSuite\jlib; (Old suite: Good-bye?)
    E:\Programs\OraDevSuite\bin; (Old suite: Good-bye?)
    E:\ORACLE\bin; ( How do I verify if this is needed by 9iDB or OEM?)
    C:\Program Files\Oracle\jre\1.3.1\bin; ( Since 9.0.3 comes with its own can I REMOVE this FROM THE DISK? )
    C:\Program Files\Oracle\jre\1.1.8\bin; ( Can I remove this from the disk? )
    C:\WINDOWS\system32;
    C:\WINDOWS;
    C:\My Programs\Java\sdk1_3\bin; ( Can I remove this from my disk? )
    **********THANK YOU!**************
    -Nat

    If you downloaded the full version of 9.0.3 Dev Preview (the 160MB sized-one), then it's completely self-contained. Just unzip it and go. Anything else can be removed.
    If you downloaded the "base" version, then you'll need to keep a JDK 1.3 around and edit your .\jdev\bin\jdev.conf file to SetJavaHome to point at your JDK home location.

  • Classpath and Path in Win2k Server

    Hi
    My OS is windows 2000 Server
    I installed Jdk 1.3.x Version.
    Do I need to set path and class path to my system to run sql package files...
    What shalll i include in my path and in class path.
    If any one having idea, please help me.
    Thanks in advance
    Yours
    Rajesh

    Dear dewangs,
    Thankyou VeryMuch
    Do I have to keep tools.jar file in my path or else in my class path ?
    Thanks in advance
    Yours
    Rajesh

  • My iMac was stolen in a robbery - no files via iCloud (long story).  I have a new iMac which is set up and being used - how do I recover old iMac files from what looks like back-up files showing on my Time Capsule (also being used for this new iMac)?

    My iMac was stolen - but I think there's a backup on my Time Capsule (which wasn't stolen). I have a new iMac which I've been using normally; I didn't use the 'Restore from...' option at the start because I thought the Time Capsule had nothing on it.  So how do I now recover files from the Time Machine?  I can see various back-ups on the Time Capsule, from various machines - laptops, etc. - but it's not letting me open any of them to see what they contain. Does anyone know how I access this information?

    Use migration assistant.
    See http://pondini.org/OSX/MigrateLion.html
    Although this is only up to Mountain Lion it is still relevant to Mavericks.. only expect Mavericks to kick and buck a lot more.

  • Question on classpath  and path

    path=.;D:\j2sdk1.4.2_04\bin;D:\j2sdk1.4.2_04\tomcat4.1\bin
    classpath=.;D:\j2sdk1.4.2_04\bin;D:\j2sdk1.4.2_04\tomcat4.1\common\lib\servlet.jar
    it work well in J2SE but doesn't work well in servlet
    what's wrong?

    I am sorry but **
    D:\javatest>javac -classpath D:\j2sdk1.4.2_04\Tomcat4.1\common\lib\servlet.jar h
    ello.java
    hello.java:6: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    hello.java:7: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    hello.java:14: cannot resolve symbol
    symbol  : class HttpServlet
    location: class com.seriousJavaProject.servlets.Hello
    public class Hello  extends HttpServlet {
                                ^
    hello.java:16: cannot resolve symbol
    symbol  : class HttpServletRequest
    location: class com.seriousJavaProject.servlets.Hello
    public void service(HttpServletRequest request,HttpServletResponse response) th
    rows IOException ,ServletException
                         ^
    hello.java:16: cannot resolve symbol
    symbol  : class HttpServletResponse
    location: class com.seriousJavaProject.servlets.Hello
    public void service(HttpServletRequest request,HttpServletResponse response) th
    rows IOException ,ServletException
                                                    ^
    hello.java:16: cannot resolve symbol
    symbol  : class ServletException
    location: class com.seriousJavaProject.servlets.Hello
    public void service(HttpServletRequest request,HttpServletResponse response) th
    rows IOException ,ServletException
                      ^
    6 errors

  • How I can set up CLASSPATH and JAVA_HOME and change default JAVA_HOME

    Hi all!
    I am new in Solaris world.
    I have installed jdk1.3.1 for Solaris.
    But default java version is 1.2.1.
    How can I set up CLASSPATH and JAVA_HOME.
    How I can change default setting.
    I need to know a name of configuration file and where can I find it?
    default java

    See code sample 3 at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    See also, the selection components row in the table under http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    It says
    One way to preselect items is to call setSelectedValue(Object[]) or setSelectedValue(Object) from the prerender() method. You pass in the return values of the items that you want preselected. Be sure to verify that getSelected() returns null before setting the default options, or you will overwrite the user's selections on a post-back.

Maybe you are looking for

  • Is Apple video adapter compatible with my 12 inch ibook G4?

    HI. Sorry if i'm repeating an old topic, but I can't seem to find this specific question in any of them. i was reading on the apple website that the video adapter M9109G/A (Model no) Is only compatible with ibook's without the external reset button?

  • Open the report

    how can I open the report run time

  • How many images per sec can I get from ImageIO.read(url) ??????

    Hello, In my program I read images from a url...I'm wondering how many images I can get with ImageIO.read(url) per second.. Hereby is the code that I'm using: import java.awt.*; //Contains all of the classes for creating user interfaces and for paint

  • Regarding Delta failures in bw.

    Hi bw guys,    This is vasu mailing a Question to of all my forum friends regarding delta failure.    This is an urgent and send me the answers to me.    when the data is coming from some tables we kept it as an Time stamp for Generic delta and it is

  • File Renaming w/ Illegal Chars

    Hi, Making a file renaming program and making it so that the user can't name files using illegal windows characters (|"/\><*?) Now I have created a case where it detects the user input if the user inputs illegal chars: for(int c = 0; c < file2.length