|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.muchsoft.util.Sys
This class lets you determine which system your Java application runs on. Furthermore, it offers methods for cross-platform queries for certain paths such as the preferences folder. It is used as follows:
if (Sys.isMacOSX()) { // Mac OS X-specific code goes here... } else { // code for other systems } // store user's configuration data DataOutputStream out = new DataOutputStream( new BufferedOutputStream( new FileOutputStream( new File( Sys.getPrefsDirectory(), "config.dat" ) ))); //...
The latest Sys version can be found at http://www.muchsoft.com/java/.
Copyright 1998-2004 by Thomas Much, thomas@muchsoft.com.
This class is free for commercial and non-commercial use,
as long as you do not distribute modified versions of the source code.
If you have any suggestions, bug reports or feature requests, let me know.
Version History:
Mac
.
Method Summary | |
static java.lang.String |
getHomeDirectory()
The home directory contains the user's data and applications. |
static java.lang.String |
getJavaHome()
The Java home directory contains the bin subdirectory and is needed to invoke the Java tools
at runtime. |
static java.lang.String |
getLocalPrefsDirectory()
The local preferences directory contains configuration files that are shared by all users on the computer. |
static java.lang.String |
getPrefsDirectory()
The preferences directory contains the user's configuration files. |
static java.lang.String |
getWorkingDirectory()
The directory from which the application was launched is called the working directory. |
static boolean |
isAMac()
|
static boolean |
isLinux()
|
static boolean |
isMacOS()
|
static boolean |
isMacOSX()
|
static boolean |
isOS2()
|
static boolean |
isWindows()
|
static void |
main(java.lang.String[] args)
This is a small test case for all the methods in this class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean isMacOS()
true
, if the application is running on Mac OS 8/9, false
otherwisepublic static boolean isMacOSX()
true
, if the application is running on Mac OS X, false
otherwisepublic static boolean isAMac()
true
, if the application is running on a Mac (OS 8, 9 or X), false
otherwisepublic static boolean isLinux()
true
, if the application is running on Linux, false
otherwisepublic static boolean isWindows()
true
, if the application is running on Windows, false
otherwisepublic static boolean isOS2()
true
, if the application is running on OS/2, false
otherwisepublic static java.lang.String getHomeDirectory()
~
and can be queried through the system property user.home
.
public static java.lang.String getWorkingDirectory()
user.dir
.
public static java.lang.String getPrefsDirectory()
~/Library/Preferences
, on all other systems the user's home directory is used.
public static java.lang.String getLocalPrefsDirectory()
/Library/Preferences
, on Linux /etc
. On all
other systems the application's working directory is used.
Please note: There is no guarantee that your application has permission to use this directory!
public static java.lang.String getJavaHome()
bin
subdirectory and is needed to invoke the Java tools
at runtime. It is specified by the environment variable $JAVA_HOME
and can be queried through
the system property java.home
. If the variable is not set properly, this method returns
/Library/Java/Home
on Mac OS X.
public static void main(java.lang.String[] args)
java -classpath .:Sys.jar com.muchsoft.util.Sys
(or java -jar Sys.jar
)
args
- not used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |