environment variables

Discussion in 'Java' started by Bill Cunningham, Apr 17, 2010.

  1. I am running MCE XP and am having a very difficult time setting
    environment variables. Is javac used anymore for the java compiler or jar
    used for jar files anymore? I am also setting up ant to build a tomcat
    server from source. I have added to path the path name of my jdk and I can
    run java from any folder. Any hints on settings for ant and tomcat?

    Bill
     
    Bill Cunningham, Apr 17, 2010
    #1
    1. Advertising

  2. Bill Cunningham

    Arne Vajhøj Guest

    On 17-04-2010 15:43, Bill Cunningham wrote:
    > I am running MCE XP and am having a very difficult time setting
    > environment variables. Is javac used anymore for the java compiler or jar
    > used for jar files anymore? I am also setting up ant to build a tomcat
    > server from source. I have added to path the path name of my jdk and I can
    > run java from any folder. Any hints on settings for ant and tomcat?


    You should set JAVA_HOME and ANT_HOME env vars and have JDK bin
    dir in PATH.

    javac and jar are still current.

    Arne
     
    Arne Vajhøj, Apr 17, 2010
    #2
    1. Advertising

  3. Arne Vajhøj wrote:

    > You should set JAVA_HOME and ANT_HOME env vars and have JDK bin
    > dir in PATH.


    I can't by reading the tutorial see how to do that.

    > javac and jar are still current.


    I can run java from any location from the DOS box. However javac and jar
    do not work.

    Bill
     
    Bill Cunningham, Apr 17, 2010
    #3
  4. Bill Cunningham

    Arne Vajhøj Guest

    On 17-04-2010 16:32, Bill Cunningham wrote:
    > Arne Vajhøj wrote:
    >> You should set JAVA_HOME and ANT_HOME env vars and have JDK bin
    >> dir in PATH.

    >
    > I can't by reading the tutorial see how to do that.


    On Windows you set them in:
    control panel
    system
    advanced
    environment

    Be very carefully not to delete anything existing!

    >> javac and jar are still current.

    >
    > I can run java from any location from the DOS box. However javac and jar
    > do not work.


    If you have installed JDK, then that indicates that you have
    not Java bin dir in PATH.

    Arne
     
    Arne Vajhøj, Apr 17, 2010
    #4
  5. On Sat, 17 Apr 2010 16:32:09 -0400, Bill Cunningham wrote:

    > Arne Vajhøj wrote:
    >
    >> You should set JAVA_HOME and ANT_HOME env vars and have JDK bin dir in
    >> PATH.

    >
    > I can't by reading the tutorial see how to do that.
    >

    Its basic operating system stuff. See your XP documentation or use a
    search engine for XP and search part or environment variable.

    >
    > I can run java from any location from the DOS box. However javac and
    > jar
    > do not work.
    >

    Fix your search path.


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Apr 17, 2010
    #5
  6. Bill Cunningham

    markspace Guest

    Bill Cunningham wrote:
    > Arne Vajhøj wrote:
    >
    >> You should set JAVA_HOME and ANT_HOME env vars and have JDK bin
    >> dir in PATH.

    >
    > I can't by reading the tutorial see how to do that.



    Just curious: which tutorial do you mean? Do you have a link?
     
    markspace, Apr 17, 2010
    #6
  7. "markspace" <> wrote in message
    news:hqdapa$pc4$-september.org...

    > Just curious: which tutorial do you mean? Do you have a link?
    >


    http://ant.apache.org/manual/index.html

    For ant . I also tried old dos paths by writing my own batch file that says
    this.

    @echo off
    set path=c:\progra~1\java\jdk1.6.0_u20\bin;%path%

    ;That works with java. But not javac or jar.

    set classpath=c:\progra~1\java\jdk1.6.0_u20\lib\tols.jar;%classpath%

    I don't know if the above set works or not. As far as these ANT_HOME and
    JAVA_HOME I have no idea what to do with them.

    Bill
     
    Bill Cunningham, Apr 17, 2010
    #7
  8. Bill Cunningham

    Arne Vajhøj Guest

    On 17-04-2010 18:27, Bill Cunningham wrote:
    > For ant . I also tried old dos paths by writing my own batch file that says
    > this.
    >
    > @echo off
    > set path=c:\progra~1\java\jdk1.6.0_u20\bin;%path%
    >
    > ;That works with java. But not javac or jar.


    It should work with javac and jar.

    Does that directory contain the two exe's?

    > set classpath=c:\progra~1\java\jdk1.6.0_u20\lib\tols.jar;%classpath%


    You should not set CLASSPATH.

    > I don't know if the above set works or not. As far as these ANT_HOME and
    > JAVA_HOME I have no idea what to do with them.


    JAVA_HOME should point to the root of Java (not the bin dir).

    It is used by many tools to locate Java.

    Similar for ANT_HOME and ant.

    Arne
     
    Arne Vajhøj, Apr 17, 2010
    #8
  9. Arne Vajhøj wrote:

    > Does that directory contain the two exe's?


    Yes. So classpath isn't set anymore to the tools.jar?

    Bill
     
    Bill Cunningham, Apr 18, 2010
    #9
  10. Bill Cunningham

    Arne Vajhøj Guest

    On 17-04-2010 19:02, Bill Cunningham wrote:
    > Arne Vajhøj wrote:
    >> Does that directory contain the two exe's?

    >
    > Yes.


    Then if the directory is in PATH then the two commands
    should work.

    > So classpath isn't set anymore to the tools.jar?


    Correct.

    CLASSPATH is a bad idea from the mid 1990's.

    Arne
     
    Arne Vajhøj, Apr 18, 2010
    #10
  11. "Arne Vajhøj" <> wrote in message
    news:4bca4053$0$272$...

    > Correct.
    >
    > CLASSPATH is a bad idea from the mid 1990's.


    Ok what about the ant variables? I've got ANT_HOMEand JAVA_HOME and have
    no idea how to set them.

    Bill
     
    Bill Cunningham, Apr 18, 2010
    #11
  12. Bill Cunningham

    Lew Guest

    Bill Cunningham wrote:
    > Ok what about the ant variables? I've got ANT_HOMEand JAVA_HOME and have
    > no idea how to set them.


    JAVA_HOME, as said upthread, is used by more than Ant.

    Peter Duniho mentioned:
    > Note: in Windows 7 (and if I recall correctly, Vista…but I'm not 100% sure
    > about that), user-specific environment variables are set in the User Accounts
    > control panel.
    >
    > The "Advanced…/Environment" dialog has a "User variables…" section, but it's
    > unreliable for non-admin accounts, because you can only even get to the dialog
    > using admin credentials (and so it always is setting environment variables for
    > some admin account).
    >
    > Of course, if one is setting system-wide environment variables, this is not a
    > concern. For my own Java use, I set the variables only for the user account I
    > am using for the dev work (which is never an admin account), but I suppose in
    > other situations system-wide settings are called for.


    You set environment variables in the way specified by the operating system,
    not Java.

    Martin Gregorie wrote:
    > Its basic operating system stuff. See your XP documentation or use a
    > search engine for XP and search part or environment variable.


    Let's say you install the JDK into 'C:\java\jdk1.6.0_u20\', a.k.a.
    'C:/java/jdk1.6.0_u20/' and Ant into 'C:/java/apache-ant-1.8.0/'.
    ..

    You'd set the environment variables JAVA_HOME='C:\java\jdk1.6.0_u20\' and
    ANT_HOME='C:\java\apache-ant-1.8.0\'.

    --
    Lew
     
    Lew, Apr 18, 2010
    #12
  13. On Sun, 18 Apr 2010 17:37:43 -0400, Lew wrote:

    > Let's say you install the JDK into 'C:\java\jdk1.6.0_u20\', a.k.a.
    > 'C:/java/jdk1.6.0_u20/' and Ant into 'C:/java/apache-ant-1.8.0/'. .
    >
    > You'd set the environment variables JAVA_HOME='C:\java\jdk1.6.0_u20\'
    > and ANT_HOME='C:\java\apache-ant-1.8.0\'.
    >

    And include C:/java/apache-ant-1.8.0/bin and C:/java/jdk1.6.0_u20/bin in
    the search path - that PATH for Linux. Dunno what it is for XP.

    Last but not least, if you're smart you'll put symbolic links in place,
    e.g. use one called C:/SDK that maps to C:/java/jdk1.6.0_u20 and do the
    same for Ant. Use the symlinks in environmental variables rather than
    the actual paths. The advantage is that, when you upgrade Java or Ant you
    simply swap the symbolic link to point to the new package without having
    to hunt down and change the environment variables.

    Disclaimer: the symlink trick works for Linux. I assume it also works for
    XP - if not, why would MS bother implementing symlinks?


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Apr 18, 2010
    #13
  14. Lew wrote:
    :

    > You'd set the environment variables JAVA_HOME='C:\java\jdk1.6.0_u20\'
    > and ANT_HOME='C:\java\apache-ant-1.8.0\'.


    I have been leaving the ' out. Maybe that's my problem. I also include
    the \bin in there so that might be part of my problem. I have also been
    including the bin directory.

    Bill
     
    Bill Cunningham, Apr 18, 2010
    #14
  15. Bill Cunningham wrote:
    > Lew wrote:
    > :
    >
    >> You'd set the environment variables JAVA_HOME='C:\java\jdk1.6.0_u20\'
    >> and ANT_HOME='C:\java\apache-ant-1.8.0\'.

    >
    > I have been leaving the ' out. Maybe that's my problem. I also include
    > the \bin in there so that might be part of my problem. I have also been
    > including the bin directory.
    >
    > Bill


    A common convention is that FOO_HOME refers to the system-*dependent*
    directory immediately containing the system-*independent* structure of
    FOO, such as directories "bin" and "docs" and "lib" and so forth. So
    ANT_HOME varies widely by individual, OS, software version etc, while
    the contents of ANT_HOME for *anyone* should be pretty much the same
    (given same or similar versions).

    Modify your PATH environment variable to account for the location of
    executables (like programs in a "bin" directory); otherwise, construct
    paths to the executables as required using the *_HOME variables (e.g.
    "%ANT_HOME%\bin").

    AHS
     
    Arved Sandstrom, Apr 18, 2010
    #15
  16. "Arved Sandstrom" <> wrote in message
    news:_QLyn.2228$Z6.1958@edtnps82...

    > A common convention is that FOO_HOME refers to the system-*dependent*
    > directory immediately containing the system-*independent* structure of
    > FOO, such as directories "bin" and "docs" and "lib" and so forth. So
    > ANT_HOME varies widely by individual, OS, software version etc, while the
    > contents of ANT_HOME for *anyone* should be pretty much the same (given
    > same or similar versions).
    >
    > Modify your PATH environment variable to account for the location of
    > executables (like programs in a "bin" directory); otherwise, construct
    > paths to the executables as required using the *_HOME variables (e.g.
    > "%ANT_HOME%\bin").


    Well this is what I've been doing. I get java but not javac or jar. So I
    know I'm doing something wrong I wrote a small batch file I call j.bat.
    Here's a copy:

    @echo off
    set path=c:\program files\java\jdk1.8.0_20\bin;%path%
    set classpath=c:\program files\java\jdk1.8.0_20\lib\tools.jar;%classpath%

    I get java but not javac or jar. Not to mention ant.

    Bill
     
    Bill Cunningham, Apr 18, 2010
    #16
  17. Bill Cunningham

    Arne Vajhøj Guest

    On 18-04-2010 18:05, Bill Cunningham wrote:
    > Lew wrote:
    >> You'd set the environment variables JAVA_HOME='C:\java\jdk1.6.0_u20\'
    >> and ANT_HOME='C:\java\apache-ant-1.8.0\'.

    >
    > I have been leaving the ' out. Maybe that's my problem.


    You should not use ''.

    > I also include
    > the \bin in there so that might be part of my problem. I have also been
    > including the bin directory.


    JAVA_HOME should point to the root.

    But it is the bin dir that needs to be in PATH.

    Arne
     
    Arne Vajhøj, Apr 19, 2010
    #17
  18. Bill Cunningham

    Arne Vajhøj Guest

    On 18-04-2010 18:48, Bill Cunningham wrote:
    > "Arved Sandstrom"<> wrote in message
    > news:_QLyn.2228$Z6.1958@edtnps82...
    >> A common convention is that FOO_HOME refers to the system-*dependent*
    >> directory immediately containing the system-*independent* structure of
    >> FOO, such as directories "bin" and "docs" and "lib" and so forth. So
    >> ANT_HOME varies widely by individual, OS, software version etc, while the
    >> contents of ANT_HOME for *anyone* should be pretty much the same (given
    >> same or similar versions).
    >>
    >> Modify your PATH environment variable to account for the location of
    >> executables (like programs in a "bin" directory); otherwise, construct
    >> paths to the executables as required using the *_HOME variables (e.g.
    >> "%ANT_HOME%\bin").

    >
    > Well this is what I've been doing. I get java but not javac or jar. So I
    > know I'm doing something wrong I wrote a small batch file I call j.bat.
    > Here's a copy:
    >
    > @echo off
    > set path=c:\program files\java\jdk1.8.0_20\bin;%path%
    > set classpath=c:\program files\java\jdk1.8.0_20\lib\tools.jar;%classpath%
    >
    > I get java but not javac or jar. Not to mention ant.


    You can drop the CLASSPATH completely.

    If you do:

    set path=c:\program files\java\jdk1.8.0_20\bin;%path%

    and:

    c:\program files\java\jdk1.8.0_20\bin\javac.exe
    c:\program files\java\jdk1.8.0_20\bin\jar.exe

    exists, then the javac and jar commands should exist.

    But somehow I doubt that those files exist.

    We are waiting for Java 1.7 - Java 1.8 is way out in
    the future.

    Arne
     
    Arne Vajhøj, Apr 19, 2010
    #18
  19. On Sun, 18 Apr 2010 18:48:15 -0400, Bill Cunningham wrote:

    > know I'm doing something wrong I wrote a small batch file I call j.bat.
    > Here's a copy:
    >
    > @echo off
    > set path=c:\program files\java\jdk1.8.0_20\bin;%path% set
    > classpath=c:\program files\java\jdk1.8.0_20\lib\tools.jar;%classpath%
    >
    > I get java but not javac or jar. Not to mention ant.
    >

    Are they actually in c:\program files\java\jdk1.8.0_20\bin - have you
    looked?

    IOW, did you install the JDK or the JRE?


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
     
    Martin Gregorie, Apr 19, 2010
    #19
  20. Arne Vajhøj wrote:

    > You can drop the CLASSPATH completely.
    >
    > If you do:
    >
    > set path=c:\program files\java\jdk1.8.0_20\bin;%path%
    >
    > and:
    >
    > c:\program files\java\jdk1.8.0_20\bin\javac.exe
    > c:\program files\java\jdk1.8.0_20\bin\jar.exe
    >
    > exists, then the javac and jar commands should exist.
    >
    > But somehow I doubt that those files exist.
    >
    > We are waiting for Java 1.7 - Java 1.8 is way out in
    > the future.


    @echo off
    set path=c:\program files\java\jdk1.8.0_20\bin;%path%
    c:\program files\java\jdk1.8.0_20\bin\javac.exe
    c:\program files\java\jdk1.8.0_20\bin\jar.exe

    I get error messages with this. I know how to set XP's enviorment
    variables in the advanced tab so I could do that. I am just writing this
    batch file. If I can get java, javac, and jar to work I would be happy and
    then work on ant.

    Bill
     
    Bill Cunningham, Apr 19, 2010
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Kasten

    Setting Environment Variables

    Rick Kasten, Jul 7, 2004, in forum: Perl
    Replies:
    2
    Views:
    611
    Howard
    Jul 7, 2004
  2. =?Utf-8?B?YnNmbDQ0?=
    Replies:
    0
    Views:
    501
    =?Utf-8?B?YnNmbDQ0?=
    May 12, 2004
  3. darrel
    Replies:
    1
    Views:
    415
    Scott Allen
    Oct 4, 2004
  4. Replies:
    5
    Views:
    687
  5. Replies:
    9
    Views:
    995
Loading...

Share This Page