i have a variable in unix, i want to pass the value of that variable to java code, so that i can use in java. One way is using properties file. Is there any other way around..??
3 Answers
You System#getenv to either get the entire environment or a single environment variable

- 10,962
- 3
- 39
- 52
-
1While correct, it would be nice if you could link to a more up-to-date reference, Java 1.5 is a little old now ;) – MadProgrammer Nov 29 '12 at 06:28
-
-
Well, technically, Java 7 is (backwards compatible), but it also allows developers to see if methods have become deprecated or if it is suggest that a better method is now available. It's a nit pick I know, but I've seen down-votes for less :P – MadProgrammer Nov 29 '12 at 06:31
-
ok that's a good reason (the deprecation), although still, when you write code others might run in another JVM, 7 is not a good idea yet. – Aviram Segal Nov 29 '12 at 06:36
public static String getenv(String name)
used to The preferred way to extract system-dependent information is the system properties of the java.lang.System.getProperty methods and the corresponding getTypeName methods of the Boolean, Integer, and Long primitive types. For example:
String classPath = System.getProperty("java.class.path",".");
A similar Question is asked here , also a good discussion here.

- 1
- 1

- 57,103
- 20
- 141
- 208
The variables have different Endianness. http://en.wikipedia.org/wiki/Endianness
As far as I can remember the endianness of data in the JVM was represented in Big-Endian and in Unix it was in Little-Endian.
You should convert it using Bytebuffer or just do it manually :P

- 304
- 1
- 7