📄 versionchecker.java
字号:
/* Stream-2-Stream - Peer to peer television and radio
* October 13, 2005 - This file has been modified from the original P2P-Radio source
* Project homepage: http://s2s.sourceforge.net/
* Copyright (C) 2005-2006 Jason Hooks
*/
/*
* P2P-Radio - Peer to peer streaming system
* Project homepage: http://p2p-radio.sourceforge.net/
* Copyright (C) 2003-2004 Michael Kaufmann <hallo@michael-kaufmann.ch>
*
* ---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* ---------------------------------------------------------------------------
*/
package p2pradio.tools;
import p2pradio.Radio;
import p2pradio.Messages;
import p2pradio.logging.Logger;
/**
* Checks if the Java version is at least 1.4. If not, it
* displays an error message (in the console and in a GUI window) and exits.
* If yes, it executes {@link Radio#main(java.lang.String[])}.
*
* @author Michael Kaufmann
*/
public class VersionChecker
{
private VersionChecker()
{
// Keine Instanzen
}
public static void startRadio(String args[], boolean isServer)
{
if (tooOldJavaVersion())
{
String msg = Messages.getString("VersionChecker.TOO_OLD_JAVA_VERSION", "1.4"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(msg);
try
{
javax.swing.JOptionPane.showMessageDialog(null, msg, Messages.getString("VersionChecker.TOO_OLD_JAVA_VERSION_TITLE"), javax.swing.JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
}
catch (Throwable t)
{
// Nichts tun, vielleicht steht gar kein Desktop
// zur Verf黦ung (gibt einen InternalError!)
}
System.exit(1);
}
try
{
new Radio(args, isServer); //We are the server
}
catch (Exception e)
{
Logger.severe("Radio", "INTERNAL_ERROR", e); //$NON-NLS-1$ //$NON-NLS-2$
}
// Radio starten
}
private static boolean tooOldJavaVersion()
{
String version;
try
{
version = System.getProperty("java.version").toLowerCase().substring(0, 3); //$NON-NLS-1$
}
catch (Exception e)
{
// Dann wird die Version eben nicht 黚erpr黤t
return false;
}
// Es kann sein, dass diese alten Versionen die Klassendateien gar nicht
// mehr lesen k鰊nen. Aber Sicherheit geht vor...
return (version.equals("1.0") || version.equals("1.1") || version.equals("1.2") || version.equals("1.3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -