This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Environment Variable!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Environment Variable!!" Watch "Environment Variable!!" New topic
Author

Environment Variable!!

Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
hi folks,
i found this about System Properties and Environment Variable. System properites is a feature that replaces the concept of
environment variables which is platform-specific
. could you please explain me why environment is a platform specific?
thanks.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi sathi
here r things which will be platform (that is OS) specific,
1. file path separator
- '\' on windows
- '/' on unix based system
- ':' on Mac OS
2. PATH separator
- ';' on windows (see ur autoexec.bat if to see how u specify multiple values for a variable).
e.g.
SET CLASSPATH=c:\java\lib\tools.jar;c:\java\lib\dt.jar
- ':' on unix based systems
e.g.
CLASSPATH=/usr/java/lib/tools.jar:/usr/java/lib/dt.jar
- i am not sure about Mac OS...u can always google..
3. line separator
- \r\n on windows
- \n on unix
- i'm not sure about Mac OS

hth
maulin
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
okay..
i forgot to mention how System Properties replaces these environment specific values..
1. file path separator
System.getProperty("file.separator")
2. PATH separator
System.getProperty("path.separator");
3. new line character
System.getProperty("line.separator");
write the following code and run on different OS to see the results,
class testSP {
public static void main(String[] s) {
System.out.println(System.getProperty("file.separator"));
System.out.println(System.getProperty("path.separator"));
System.out.println(System.getProperty("line.separator").length());
}
}
regards
maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Environment Variable!!
 
Similar Threads
Can't compile a simple program.
J2MEWTK for Linux: mis-sized emulator window
Property
jboss google and mail classloading
Passing environment information to native processes