import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class RunEclipse {
private static String picFolder = "mysplash";
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
makeFolder(picFolder);
String runString = "eclipse.exe -showsplash ";
runString += picFolder;
runString += "\\";
runString += getShowPictureName(picFolder);
Runtime rt = Runtime.getRuntime();
rt.exec(runString);
}
private static void makeFolder(String folder) {
File file = new File(folder);
if (!file.exists()) {
file.mkdir();
}
}
/**
* @param args
*/
private static String getShowPictureName(String filePath) {
int picCount = 0;
List<String> picList = new ArrayList<String>();
String strRun = "";
File file = new File(filePath);
if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
if (filelist[i].toLowerCase().endsWith(".bmp")) {
picCount++;
picList.add(filelist[i]);
}
}
if (picCount > 0) {
Random rand = new Random();
int index = rand.nextInt(picCount);
strRun = filelist[index];
}
}
return strRun;
}
}
修改Eclipse启动图片
最新推荐文章于 2020-11-10 09:23:39 发布
本文介绍了一个使用Java编写的Eclipse启动器程序,该程序能够随机选择一个.bmp格式的图片作为启动时显示的splash屏幕,并通过Runtime类执行Eclipse。文章首先创建了指定文件夹用于存放splash图片,然后通过获取该文件夹下所有.bmp图片名称,随机选取一张作为启动时显示的图片。
5940

被折叠的 条评论
为什么被折叠?



