• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Environment Variable!!

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic