2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
20 package jalview.bin;
\r
24 import java.util.jar.*;
\r
27 public static String VERSION = "Release 2.0";
\r
28 public static String BUILD_DATE = "";
\r
30 public static Properties applicationProperties;
\r
31 // Current properties include:
\r
33 // LAST_DIRECTORY , use this to cache record of where the user looked to find a file
\r
35 // USER_DEFINED_COLOUR - file describing last user set colours
\r
39 // logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services)
\r
40 // jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do.
\r
41 public static void loadProperties()
\r
43 // get last build time.
\r
46 String localFile = Cache.class.getProtectionDomain().getCodeSource().getLocation().toString();
\r
47 localFile = localFile.concat("!/");
\r
48 String tmpString = "jar:";
\r
49 String localJarFileString = tmpString.concat(localFile);
\r
50 java.net.URL localJarFileURL = new java.net.URL(localJarFileString);
\r
51 java.net.JarURLConnection localJarFile = (java.net.JarURLConnection)localJarFileURL.openConnection();
\r
52 date = localJarFile.getLastModified();
\r
53 }catch(Exception ex){ex.printStackTrace();}
\r
56 // this is called for unpackaged class files, ie not in a Jar file
\r
57 // InstallAnywhere version will find build date this way
\r
58 // not entirely accurate as it only tells you when Cache.class was last compiled
\r
61 java.io.File f = new java.io.File(System.getProperty("user.dir") + "/jalview/bin/Cache.class" );
\r
62 date = f.lastModified();
\r
66 BUILD_DATE = new Date( date ).toString();
\r
68 applicationProperties = new Properties();
\r
72 FileInputStream in = new FileInputStream(System.getProperty("user.home") +
\r
73 "/.jalview_properties");
\r
74 applicationProperties = new Properties();
\r
75 applicationProperties.load(in);
\r
78 catch (Exception ex)
\r
82 public static String getProperty(String key)
\r
84 return applicationProperties.getProperty(key);
\r
87 public static String setProperty(String key, String obj)
\r
91 FileOutputStream out = new FileOutputStream(System.getProperty(
\r
92 "user.home") + "/.jalview_properties");
\r
94 applicationProperties.setProperty(key, obj);
\r
96 applicationProperties.store(out, "---JalviewX Properties File---");
\r
99 catch (Exception ex)
\r