environment variables

B

Bill Cunningham

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
 
A

Arne Vajhøj

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
 
B

Bill Cunningham

Arne said:
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
 
A

Arne Vajhøj

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!
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
 
M

Martin Gregorie

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

Bill Cunningham

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
 
A

Arne Vajhøj

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
 
B

Bill Cunningham

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
 
L

Lew

Bill said:
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 said:
> 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\'.
 
M

Martin Gregorie

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?
 
B

Bill Cunningham

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

Arved Sandstrom

Bill said:
Lew wrote:
:


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
 
B

Bill Cunningham

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
 
A

Arne Vajhøj

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
 
A

Arne Vajhøj

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
 
M

Martin Gregorie

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?
 
B

Bill Cunningham

Arne said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top