CLASSPATH environment variable - Pro/cons?

I was told that its not a good idea to define CLASSPATH as a system environment variable, but was never told why. Is it correct that it should be avoided to define CLASSPATH as a system variable?
Another thing when should a variable be defined as a system variable or an user variable?

fedevaps wrote:
I was told that its not a good idea to define CLASSPATH as a system environment variable, but was never told why. Is it correct that it should be avoided to define CLASSPATH as a system variable?For one thing, it means you have no control over classpaths. Say you write two apps, and they each use a different version of the same library. If you're using the one global classpath for both of them, you're stuffed. How do you allow them both to use the correct version? Then you come to deploy one of them on someone else's machine, and, say, send them a CD with it on."Right, what jars does it use again? I dunno. It always just worked, cos I've got all my dependencies in one place, and the VM picks up the lot. Goddammit. I'll have to put all of them on his machine, too .AND set up his classpath. What? There are 500 machines to roll out to? And some of them don't even +have+ that folder? Goddammit! ". See the problem? If you explicitly dictate a classpath when starting up the JVM, it can be wherever you want - typically a lib folder within that specific app - and have exactly what you need on it. Much more flexible and easier to control
Another thing when should a variable be defined as a system variable or an user variable?I hope you're just asking cos you're already here, and not because you think this is related to Java. Cos it isn't. System variables are available to, well, all the users of the machine, including any local accounts that services might be running under. A user variable is specific to the user it's defined for, and not visible to any others. When you use which depends very much on what the variable is for

Similar Messages

  • How to load a class , which isn't in the classpath environment variable.

    Hi, you folks.
    I have one problem. I want to load a class, which isn't in the classpath
    environment variable and I don't want to put into classpath. which method
    JVM can use to load it?
    Waitting for your sage advice.
    Regareds
    Hunter.Xiao

    You will have to write your own ClassLoader, or use something like URLClassLoader (I've never used this myself, but I've seen it mentioned elsewhere in this forum). Look here.

  • CLASSPATH Environment Variable on Win2k problem

    hi
    i am new to java, but having problems to seting the CLASSPATH Environment Variable on my Win2k professional. my university computers are alredy set and i enjoy working with java. i just cant get my head arround to this problem. it would be much appriciated if some one send me a link which provide screenshot to resolve this problem. i got my jdk1.4 kit in a folder caled jdk in c:\ root.
    thanks

    Ashwani_Saxena wrote:
    Our application is stand-alone application and we are using Applet with Object Id tag for JavaScript to Java connectivity. In our application we are displaying the value of classpath environment variable on screen.
    Applets and stand alone applications are two different animals.
    While migrating from JRE 1.5 to JRE 1.6, we are unable to retrieve the classpath variable value. After analyzing, figure out that when classpath is defined in uppercase (i.e. CLASSPATH) then only we are unable to retrieve its value. However if its defined in lower case or any character is in lower case (i.e. classpath) then its value appears correctly. We are retrieving the classpath value via the "Set" command from Java.
    That's completely unnecessary, there's a System.getevn("CLASSPATH") method.
    However the CLASSPATH environmental variable isn't much use, and certainly not in the case of Applets, which definitely don't use it.
    Futhermore I don't expect the sandbox environment of an Applet will allow you to access the environmental variables in any way, (certainly not by running a program). Applets, unless signed, have almost no access to the client machine they run on.

  • Jar file doesn't read classpath environment variable from windows xp

    I created a small program that uses javamail and jdbc driver. I program on Win XP and use java 1.6.04.
    When I compiled my classes the program works fine but when I created a jar package the jar file cannot 'see' the classpath that windows has already set.
    I have to set the classpath in the manifest file and then it works ok.
    Is this normal? I was expecting that the jar file would work just fine without any complication since the classpath is already set in the system?
    If you could point to any documentation that covers this it would be great.
    Thank you very much.
    Genti

    genti_tech wrote:
    I specified the class-path in manifest in jar file and I looked at the tutorial you are suggesting:
    http://java.sun.com/docs/books/tutorial/deployment/jar/
    which is not clear at all about the fact that jar ignores the class-path environment variable.It is specified for java. http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html#-jar

  • OC4J classpath & environment variables

    Hi,
    What do I have to have in my classpath?
    What environment variables I need to have?
    Do I have to install JDK X.XX before I install OC4J or does OC4J comes packaged with a JDK?
    Thanks
    Nabil

    I think you should install JDK1.2.2_07 or 1.3.x before you install OC4J. I am using JDK 1.3.1 now. I had used JDK 1.2.2_05 and _08, but when I start OC4J, there was a NON-FATAL error message. Although it's NON-FATAL, I still don't like it. So I moved to JDK 1.3.1. My classpath in system environment variable is ".;", nothing else.
    But if you are going to use OCI8 JDBC driver,
    you'd better replace the classes12.jar under OC4J\lib with classes12.zip coming with Oracle8i Client 8.1.7.3. otherwise, you will encounter an "UnsatisfiedLinkError" when you use the datasource to get connection. In addition, you should set the "path" variable in order to run Oracle8i client. You can find the information from Oracle8i'd documentation.
    Good Luck!

  • Setting Linux environment variable

    Is there other web site which talks about how to set the environment variable of J2EE for Linux?
    I followed this web site
    http://www.dougsparling.com/comp/howto/linux_java.html
    but after all
    when I tired to compile a servlet program... it couldn't be complied. I think the case is that the compiler couldn't find servlet.jar ...
    why is that?

    You have to verify that your CLASSPATH environment variable is set in your account's profile. I use the
    bash shell therefore my variables are set in .bashrc
    for example my CLASSPATH is set to :
    CLASSPATH=.:$J2EE_HOME/lib/j2ee.jar:$J2EE_HOME/lib/locale

  • R12, Environment Variables on Windows, and OBIEE

    Dear Experts,
    I've managed to install R12 on Windows.
    Now, in the global environment variable, Path, the user Oracle has a number of directories in its default PATH, starting with the Oracle apps middle tier.
    C:\oapps\apps\tech_st\10.1.2\bin;     
    C:\oapps\apps\tech_st\10.1.2\jdk\jre\bin\classic;     
    C:\oapps\apps\tech_st\10.1.2\jdk\jre\bin;
    C:\oapps\apps\tech_st\10.1.2\jlib;     
    C:\oapps\apps\tech_st\10.1.3\bin;     
    C:\oapps\db\tech_st\11.1.0\bin;     
    C:\Windows\system32;     
    C:\Windows;     
    I notice that there are .cmd scripts that set the Path.
    This script sets the path to look in: c:\oapps\db
    cd C:\oapps\db\tech_st\11.1.0
    VIS_black.cmd
    echo %PATH%
    C:\oapps\db\tech_st\11.1.0\perl\5.8.3\bin\MSWin32-x86-multithread\;
    C:\oapps\db\tech_st\11.1.0\bin;
    This script sets the path to look in: c:\oapps\apps
    set PATH=""
    cd c:\oapps\apps\apps_st\appl
    VIS_black.cmd
    echo %PATH%
    C:\oapps\apps\apps_st\appl\au\12.0.0\bin;
    I'd like to install OBIEE on the same server. Obviously, I don't want any path conflicts. And, OBIEE uses a different version of java.
    1)
    Do all these Apps directories need to remain in the global PATH environment variable? Or, can the directories be removed from the path, and the scripts can be relied on to set the appropriate variables?
    Thanks a lot!

    if you want global settings (always present, even after reboot), you have to edit the autoexec.bat file, e..g
    SET CLASSPATH=c:\myclasses
    you can set environment variables temporarility in a DOS shell using the same command.
    if possible, you should avoid the CLASSPATH environment variable, and use the -cp or -classpath option for java and javac. This helps a lot to solve classpath confusions.

  • X11 environment variables on MacBook Pro

    Hi
    I have just got my new MacBook Pro and have installed Gimp to run using x11 that came on the apple installation disks however I can't seem to get the xterm to configure correctly.
    GIMP is installed under /sw/bin but the default PATH for x11 does not include this location so I added PATH=$PATH:/sw/bin:/sw/sbin to a newly created .bash_profile. But x11 did not seem to use this file although terminal worked OK.
    After doing a bit of research, I then created a .bashrc file with the PATH defined and changed the .bash_profile to source .bashrc with no other entries.
    Again this worked OK for Terminal but now when I type 'echo $Path' in an x11 xterm the PATH displays two entries for /sw/bin & /sw/sbin. i.e.
    $ echo $PATH
    /usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/sw/bin:/sw/sbin:/sw/bin:/sw/sbin
    Any ideas why? and how can I correct it?
    Macbook Pro 17   Mac OS X (10.4.9)  

    Sorry this was a bit brief; I think I was still asleep when I typed it.
    The reasons are these:
    1. Many fink programs require environment variables and other settings. When you source that init.sh file, it ensures everything is set up to work out of the box. (Among the things it does is to in turn source every relevant file in /sw/etc/profile.d -- take a look in it to see what, if anything, is in there). There is also some code to keep your path trimmed properly, so you don't get repeats pasted on.
    2. Bash is unique in that either .bashrc or .bash_profile, but not both, get sourced. In a rooted X11 environment, everything works properly, but on OS X, where X11 is "rootless," it leads to unexpected behavior like what you saw. As long as you put everything into one file and then tell the other one to source its contents, you should be ok.
    You can also run X11 stuff from Apple's terminal, provided you somewhere in a startup file have something to set the DISPLAY variable, usually to .0.
    I've put more discussion of these things here

  • Environment variables like classpath,JAVA_HOME,path

    Sir,
    I work as a java developer in a software company.I had more problems when executing servlets."could not create the java vitual machine" error comes when i try to compile java servlet file.also I do not know that how to set environment variables like classpath,path and JAVA_HOME.Also I want to know them with proper examples.
    Thanking you.
    KRamesh

    Hi Teches
    I am facing few problem in starting eclipse 3.0 ; I had gone trogh forum , 1 of the persone suggest me to upgrade the java version.For this
    I had installed java 1.5 and set the following variable
    JAVA_HOME ---> to the home dir of JAVA
    PATH ---><home dir>/bin
    CLASSPATH --><jre>/lib
    But when ever i m giving "java -version" command on console , the result is as follows:
    C:\>java -version
    java version "1.3.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
    Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
    suggestion are welcome Plz.
    ;

  • Classpath in Environment Variables

    Dear All,
    After I put " ; " in front of Environment Variables in Win XP System Properties
    so my classpath=;C:\tomcat4\common\lib\servlet.jar;C:\tomcat4\webapps\aplikasiku\WEB-INF\lib\mssqlserver.jar;C:\tomcat4\webapps\aplikasiku\WEB-INF\lib\msbase.jar;C:\tomcat4\webapps\aplikasiku\WEB-INF\lib\msutil.jar. then my problem solved. I never found NoClassDefFoundError in my java.
    Is it ok to use that classpath?
    Thanks

    Hi,
    It can be used but should really really be avoided since it makes it makes it very hard to use when you have multiple applications, and applications of different versions.
    Kaj

  • Java classpath with Environment variable..

    Hi,
    I need to start an Java application with an Environment variable(EV) as class path.
    Ex:
    I have an EV APP_PATH =c:\myapp
    so i will give java -cp c:\myapp, instead of doing like this I need to give APP_PATH in the java -cp<EV>.
    I gave like this java -cp %APP_PATH% and that doesn't work...
    Is this the correct way or how to do this ?
    Thanks.

    I gave like this java -cp %APP_PATH% and that doesn't
    work...It does if APP_PATH has the correct value.
    Try echo %APP_PATH% and see if it's what you expect. They plug whatever that returns into your java command.
    Is this the correct way or how to do this ?That's the correct way. You APP_PATH must be wrong.

  • Setting my classpath in XP (pro)

    how do I set my classpath in XP Pro for my java software??
    i have got j2sdk1.4.1_01 and i rekon that the path should lead to the bin directory??
    This is obviosly very basic stuff, but I just cant get it right.
    I can compile (javac filename.java) without any problems, nut when i run (java filename), its saying that it can't fine java.dll and it couldnt find the Java 2 Runtime Environment!!!
    Please help, this is driving me crazy.
    Jim

    1. Right click My Computer on the desktop, select Properties
    2. Click "Advanced" tab
    3. Click "Environment Variables" button
    4. Select "Path" in "System variables" and click "Edit" button
    5. Enter "C:\j2sdk1.4.1_01\bin;" to the beginning of Path
    6. Select "OK" etc....it's done
    Depending on what applications you have on your system, you may have some classpath conflicts, but this should fix it for you.

  • Error Message:PRVF-3929 - PATH environment variable.

    Hello,
    I am trying to install Oracle on my laptop and getting the following error message resulting into hault of installation.
    INFO: *********************************************
    INFO: Environment variable: "PATH": This test checks whether the length of the environment variable "PATH" does not exceed the recommended length.
    INFO: Severity:CRITICAL
    INFO: OverallStatus:VERIFICATION_FAILED
    INFO: -----------------------------------------------
    INFO: Verification Result for Node:Indrajit-PC
    INFO: Expected Value:1023
    INFO: Actual Value:1159
    INFO: Error Message:PRVF-3929 : Adding the Oracle binary location to the PATH environment variable will exceed the OS length limit of [ "1023" ] for the variable on the node "Indrajit-PC"
    INFO: Cause: The installer needs to update the PATH environment variable to include the value "%ORACLE_HOME%/bin;".
    However, doing so will cause PATH to exceed the maximum allowable length that this operating system allows.
    INFO: Action: Ensure that the sum of the lengths of your current PATH environment variable and that of
    "%ORACLE_HOME%/bin;" does not exceed the operating system limit.
    Restart the installer after correcting the setting for environment variable.
    Oracle Database Trying ton install - win64_11gR2
    MY PC CONFIGURATION:
    - Windows 7
    - 64 bit
    Can you please help me getting this solved please.

    C:\>Set
    ALLUSERSPROFILE=C:\ProgramData
    APPDATA=C:\Users\Indrajit\AppData\Roaming
    asl.log=Destination=file
    CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
    CommonProgramFiles=C:\Program Files\Common Files
    CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
    CommonProgramW6432=C:\Program Files\Common Files
    COMPUTERNAME=INDRAJIT-PC
    ComSpec=C:\Windows\system32\cmd.exe
    COPLIB=C:\Program Files (x86)\Teradata\Client\13.0\CLIv2\
    DataConnectorLibPath=C:\Program Files (x86)\Teradata\Client\13.0\bin
    FP_NO_HOST_CHECK=NO
    HOMEDRIVE=C:
    HOMEPATH=\Users\Indrajit
    JAVA_HOME=C:\Program Files\Java\jdk1.7.0
    LOCALAPPDATA=C:\Users\Indrajit\AppData\Local
    localtd=1
    LOGONSERVER=\\INDRAJIT-PC
    NUMBER_OF_PROCESSORS=4
    OS=Windows_NT
    Path=C:\Program Files (x86)\AXSMOD;C:\Program Files (x86)\Teradata\Client\13.0\A
    XSMOD\;C:\Program Files (x86)\Teradata\Client\13.0\bin;C:\Program Files (x86)\Te
    radata\Client\13.0\bin;C:\Program Files (x86)\Teradata\Client\13.0\CLIv2\;C:\Pro
    gram Files (x86)\Teradata\Client\13.0\ODBC Driver for Teradata\Lib;C:\Program Fi
    les\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
    es\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\Syste
    m32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI
    Technologies\ATI.ACE\Core-Static;c:\Program Files\WIDCOMM\Bluetooth Software\;c:
    \Program Files\WIDCOMM\Bluetooth Software\syswow64;;C:\Program Files\Dell\DW WLA
    N Card\Driver;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\
    QuickTime\QTSystem\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;
    C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft
    SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.7.0\bin;C:\Program Files (x
    86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Teradata\Client\
    13.0\Shared ICU Libraries for Teradata\lib\;C:\Program Files (x86)\AXSMOD;
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    PROCESSOR_ARCHITECTURE=AMD64
    PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 5, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=2505
    ProgramData=C:\ProgramData
    ProgramFiles=C:\Program Files
    ProgramFiles(x86)=C:\Program Files (x86)
    ProgramW6432=C:\Program Files
    PROMPT=$P$G
    PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
    PUBLIC=C:\Users\Public
    QTJAVA=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\Windows
    TEMP=C:\Users\Indrajit\AppData\Local\Temp
    TMP=C:\Users\Indrajit\AppData\Local\Temp
    USERDOMAIN=Indrajit-PC
    USERNAME=Indrajit
    USERPROFILE=C:\Users\Indrajit
    windir=C:\Windows

  • Error in setting environment variable

    hi
    Please note JKit is where my jdk1.3 is stored(i.e instead of jdk1.3 folder its JKit folder)... i have gone thru the similar threads but with no success.
    SET
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;D:\Jkit\bin;D:\Jkit\lib;D:\Oracle\bin;"C:\PROGRAMFILES\ORACLE\JRE\1.1.7\BIN";D:\JKit\Jre\Bin;
    SET PATH=%PATH%;C:\PROGRA~1\COMMON~1\AUTODE~1;
    SET CLASSPATH=c:\JavaWebServer2.0\lib\servlet.jar;c:\JKit\lib;
    SET CATALINA_HOME=D:\tomcat\jakarta-tomcat-4.1.29;
    SET JAVA_HOME=D:\Jkit;
    The error i get after running autoexec.bat and then tomcat/bin/startup is as follows..
    The CATALINA_HOME environment variable is not defined
    This environment variable is needed to run this program
    please HELP!!.THANKS

    Hi
    Very many thanks for ur solution.. i actually hadset the environment variables spacce..but when i execute the autoexec.bat file i dont get any error(out of env space)..but when i run the startup.bat file i get from the command prompt, i get the foll error.
    This is my Autoexec.bat
    SET JAVA_HOME=D:\Jkit\bin
    SET CATALINA_HOME=D:\tomcat\jakarta-tomcat-4.1.29\bin
    SET PATH=D:\Jkit\bin;C:\WINDOWS;C:\WINDOWS\COMMAND;
    SET PATH=%PATH%;C:\PROGRA~1\COMMON~1\AUTODE~1;
    THE FOLLOWING IS THE ERROR I GET WHEN I RUN STARTUP.BAT UNDER TOMCAT'S BIN UNDER THE COMMAND PROMPT
    D:\tomcat\jakarta-tomcat-4.1.29\bin>startup
    Syntax error
    Out of environment space
    Out of environment space
    Out of environment space
    Using CATALINA_BASE: D:\tomcat\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: D:\tomcat\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: D:\tomcat\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: D:\Jkit
    Out of environment space
    Out of environment space
    Invalid switch - -DJAVA.ENDORSED.DIRS=D:\TOMCAT\JAKARTA-TOMCAT-4.1.29\COMMON\ENDORSED
    I even set JAVA_HOME AND CATALINE_HOME to the \bin dir respectively..
    still i get the same error
    As given under the tomcat installation documentation (RUNNING.txt), i set the space for environment space under the Memory tab, for startup and shutdown.bat files, it creates a shortcut for running the resp .bat files, running startup.bat file i get,CATALINA_HOME VAR HAS NOT BEEN SET PROPERLY, THIS OCCURS FOR BOTH TOP LEVEL DIR SETTING AND /bin DIR SETTING of CATALINE_HOME IN autoexec.bat
    PLEASE HEL, I HAVE BEEN TRYING TO CONFIGURE IT FOR THE PAST DAYS BUT WITH NO SUCCESS, DONT KNOW WHERE I AM GOING WRONG..PLEASE HELP

  • Open module for managing property file and environment variables

    Looking for an open module for managing property files and environment variables (like CLASSPATH) set in a shell script. For handeling properties (preserving comments, supporting includes, appending new entries, and more) I have looked at SuperProperties from openadaptor but find certain functionality lacking. As for interfacing with common shell scripts/files containing setting for CLASSPATH, JAVA_HOME, other system/application variables another type of object editor is needed. Maybe JFIG?
    Any ideas are greatly welcomed.

    You seem wright, you hit a brick wall here with Air to find the location
    of the command console on windows...
    So in fact I never build an exe tool, but this little problem was a nice
    case to test it and I tried it.:
    I downloaded monodevelop
    -GTK# for .NET 2.12.10*
    -MonoDevelop 2.4.2*
       from http://monodevelop.com/Download
    created a console project and had an exe in 5 minutes !
    You can download the findconsole tool and the projectfiles here:
       http://greencollective.nl/temp/dump/findconsole_monoproject.zip
    findconsole.exe will reveal the path/location of cmd.exe on a windows system.
    Cheers,
    Latcho

Maybe you are looking for