
正文
代码获取当前java版本 代码获取当前java版本信息
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
JAVA里静态的属性怎么在jsp里访问?
第一代码获取当前java版本:如果是对象的话代码获取当前java版本,代码获取当前java版本你应该去看看jsp:bean的用法。只有配合使用jsp:getProperty才有用
第二:是静态的函数,也就不怕了。代码获取当前java版本你在
%@ page language="java" import="java.util.*,com.rh.entity.*" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%
import="java.util.*,com.rh.entity.*" 加上这句,当然是你的Infomation 类的全路径,你就可以在jsp中用了
%=Infomation.getJavaRuntimeVersion() %
相关问答
Q1: 怎么用Java代码查出git代码的当前版本号
@RequestMapping("/git/version")
public String getGitVersion() {
try {
//需要安装git并配置git环境变量
String command = "git --version";
//执行系统命令
Process p = Runtime.getRuntime().exec(command);
//获取命令执行结果,封装在IO流中了
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String
//输出结果
String s;
StringBuilder sb = new StringBuilder();
while ((s = br.readLine()) != null) {
sb.append(s);
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Q2: java代码怎么获取git版本
拉取远程仓库:$ git pull [remoteName] [localBranchName]
git pull:从其他的版本库(既可以是远程的也可以是本地的)将代码更新到本地,例如:'git pull origin master'就是将origin这个版本库的代码更新到本地的master主枝,该功能类似于SVN的update
Q3: java获得当前服务器的操作系统是什么?怎么获得
import java.util.Properties;
public class Test{
public static void main (String args[]){
Properties props=System.getProperties(); //系统属性
System.out.println("Java的运行环境版本:"+props.getProperty("java.version"));
System.out.println("Java的运行环境供应商:"+props.getProperty("java.vendor"));
System.out.println("Java供应商的URL:"+props.getProperty("java.vendor.url"));
System.out.println("Java的安装路径:"+props.getProperty("java.home"));
System.out.println("Java的虚拟机规范版本:"+props.getProperty("java.vm.specification.version"));
System.out.println("Java的虚拟机规范供应商:"+props.getProperty("java.vm.specification.vendor"));
System.out.println("Java的虚拟机规范名称:"+props.getProperty("java.vm.specification.name"));
System.out.println("Java的虚拟机实现版本:"+props.getProperty("java.vm.version"));
System.out.println("Java的虚拟机实现供应商:"+props.getProperty("java.vm.vendor"));
System.out.println("Java的虚拟机实现名称:"+props.getProperty("java.vm.name"));
System.out.println("Java运行时环境规范版本:"+props.getProperty("java.specification.version"));
System.out.println("Java运行时环境规范供应商:"+props.getProperty("java.specification.vender"));
System.out.println("Java运行时环境规范名称:"+props.getProperty("java.specification.name"));
System.out.println("Java的类格式版本号:"+props.getProperty("java.class.version"));
System.out.println("Java的类路径:"+props.getProperty("java.class.path"));
System.out.println("加载库时搜索的路径列表:"+props.getProperty("java.library.path"));
System.out.println("默认的临时文件路径:"+props.getProperty("java.io.tmpdir"));
System.out.println("一个或多个扩展目录的路径:"+props.getProperty("java.ext.dirs"));
System.out.println("操作系统的名称:"+props.getProperty("os.name"));
System.out.println("操作系统的构架:"+props.getProperty("os.arch"));
System.out.println("操作系统的版本:"+props.getProperty("os.version"));
System.out.println("文件分隔符:"+props.getProperty("file.separator")); //在 unix 系统中是”/”
System.out.println("路径分隔符:"+props.getProperty("path.separator")); //在 unix 系统中是”:”
System.out.println("行分隔符:"+props.getProperty("line.separator")); //在 unix 系统中是”/n”
System.out.println("用户的账户名称:"+props.getProperty("user.name"));
System.out.println("用户的主目录:"+props.getProperty("user.home"));
System.out.println("用户的当前工作目录:"+props.getProperty("user.dir"));
}
}
Q4: java 判断当前操作系统是不是windows
Java 判断操作系统是linux还是windows代码获取当前java版本,主要是使用system这个类,这个类型提供了获取java版本、安装目录、操作系统等等信息,代码如下:1
2
System.out.println("===========操作系统是:"+System.getProperties().getProperty("os.name"));
System.out.println("===========文件代码获取当前java版本的分隔符为file.separator:"+System.getProperties().getProperty("file.separator"));
System类
public static Properties getProperties()
将 getProperty(String) 方法使用代码获取当前java版本的当前系统属性集合作为 Properties 对象返回
键 相关值代码获取当前java版本的描述
java.version Java 运行时环境版本
java.vendor Java 运行时环境供应商
java.vendor.url Java 供应商的 URL
java.home Java 安装目录
Q5: Java代码获取服务器所装office版本
可以呀,访问注册表,给你一段代码自己看吧。
import java.util.ArrayList;
import java.lang.reflect.Method;
final class WinRegisterUtil {
// root key value defined by windows
public static final int HKEY_CLASSES_ROOT = 0x80000000;
public static final int HKEY_CURRENT_USER = 0x80000001;
public static final int HKEY_LOCAL_MACHINE = 0x80000002;
public static final int HKEY_USERS = 0x80000003;
public static final int HKEY_PERFORMANCE_DATA = 0x80000004;
public static final int HKEY_CURRENT_CONFIG = 0x80000005;
//Constants used to interpret returns of native functions
public static final int NATIVE_HANDLE = 0;
public static final int ERROR_CODE = 1;
//Windows security masks
public static final int DELETE = 0x10000;
public static final int KEY_QUERY_VALUE = 1;
public static final int KEY_SET_VALUE = 2;
public static final int KEY_CREATE_SUB_KEY = 4;
public static final int KEY_ENUMERATE_SUB_KEYS = 8;
public static final int KEY_READ = 0x20019;
public static final int KEY_WRITE = 0x20006;
public static final int KEY_ALL_ACCESS = 0xf003f;
//error codes
public static final int ERROR_SUCCESS = 0;
public static final int ERROR_FAILED = -1;
private static final Integer MAX_KEY_LENGHT = new Integer(100);
private static final Class theClass = getUtilClass();
private static Class getUtilClass() {
try {
return Class.forName("java.util.prefs.WindowsPreferences");
}
catch (Exception e) {
return null;
}
}
// hKey: 跟键,列在类头,HKEY_CURRENT_USER
// subKey: 相对hKey的路径,例如:"Software\\ODBC"
// securityMask:读写权限,列在类头,KEY_ALL_ACCESS
public static int[] windowsRegOpenKeyEx(int hKey, String subKey,
int securityMask) {
try {
Method m = theClass.getDeclaredMethod("WindowsRegOpenKey",
new Class[] {int.class, byte[].class, int.class});
m.setAccessible(true);
Object ret = m.invoke(null, new Object[] {new Integer(hKey),
stringToByteArray(subKey), new Integer(securityMask)});
return (int[]) ret;
}
catch (Exception e) {
System.out.println("Exception windowsRegOpenKeyEx!");
return new int[] {
0, ERROR_FAILED};
}
}
// 关闭注册表
public static void windowsRegCloseKey(int hKey) {
try {
Method m = theClass.getDeclaredMethod("WindowsRegCloseKey", new Class[] {int.class});
m.setAccessible(true);
m.invoke(null, new Object[] {new Integer(hKey)});
}
catch (Exception e) {
System.out.println("Exception windowsRegCloseKey!");
}
}
// hKey父键的句柄
// key子键的字符串,是中文时取不到
public static String windowsRegQueryValueEx(int hKey, String key) {
try {
Method m = theClass.getDeclaredMethod("WindowsRegQueryValueEx",
new Class[] {int.class, byte[].class});
m.setAccessible(true);
Object value = m.invoke(null, new Object[] {new Integer(hKey),
stringToByteArray(key)});
if (value == null) {
return null;
}
return winByteArrayToString( (byte[]) value);
}
catch (Exception e) {
System.out.println("Exception windowsRegQueryValueEx!");
return null;
}
}
// 枚举hKey下的值,valueIndex从0开始计数
public static String windowsRegEnumValue(int hKey, int valueIndex) {
try {
Method m = theClass.getDeclaredMethod("WindowsRegEnumValue",
new Class[] {int.class, int.class, int.class});
m.setAccessible(true);
Object value = m.invoke(null, new Object[] {new Integer(hKey),
new Integer(valueIndex), MAX_KEY_LENGHT});
return winByteArrayToString( (byte[]) value);
}
catch (Exception e) {
System.out.println("Exception windowsRegEnumValue!");
return null;
}
}
private static byte[] stringToByteArray(String str) {
byte[] result = new byte[str.length() + 1];
for (int i = 0; i str.length(); i++) {
result[i] = (byte) str.charAt(i);
}
result[str.length()] = 0;
return result;
}
private final static String winByteArrayToString(byte[] array) {
if (array == null) {
return null;
}
int pos = array.length - 1;
while (pos = 0) {
if (array[pos] != '\0') {
break;
}
pos--;
}
if (pos = 0) {
return new String(array, 0, pos + 1);
}
else {
return null;
}
}
}
关于代码获取当前java版本和代码获取当前java版本信息的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







