feat: [#294] make launcher compatable with Java 9 and newer
This commit is contained in:
parent
ed5875a691
commit
7eaaaad3a9
13 changed files with 111 additions and 38 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@
|
|||
!/.vscode/launch.json
|
||||
!/.github/
|
||||
!/.mvn/
|
||||
!/getMemory/
|
||||
!/src/
|
||||
!/macapp/
|
||||
!/.editorconfig
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 3.2.6.1
|
||||
## 3.2.7.0
|
||||
|
||||
- Warn if users aren't on at least version 101 of Java 8
|
||||
- Change authlib version to 1.5.21 to fix issues with needing Java 8
|
||||
- Don't allow empty password when launching Minecraft without saved password
|
||||
- Fix view mods button not working
|
||||
- Remove old xml code from 2014 no longer user
|
||||
- Make launcher compatable with Java 9 and newer
|
||||
|
|
3
getMemory/.gitignore
vendored
Normal file
3
getMemory/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
getMemory-linux
|
||||
getMemory-osx
|
||||
getMemory.exe
|
9
getMemory/Dockerfile
Normal file
9
getMemory/Dockerfile
Normal file
|
@ -0,0 +1,9 @@
|
|||
FROM golang:latest
|
||||
|
||||
RUN mkdir /app
|
||||
ADD getMemory.go /app/
|
||||
WORKDIR /app
|
||||
RUN go get github.com/pbnjay/memory
|
||||
RUN GOOS=windows GOARCH=386 go build -o getMemory.exe getMemory.go
|
||||
RUN GOOS=linux GOARCH=386 go build -o getMemory-linux getMemory.go
|
||||
RUN GOOS=darwin GOARCH=386 go build -o getMemory-osx getMemory.go
|
34
getMemory/README.md
Normal file
34
getMemory/README.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# getMemory
|
||||
|
||||
This small go program simply prints out the detected system ram in the system
|
||||
|
||||
To build you will need to have go installed, and then run:
|
||||
|
||||
```sh
|
||||
go get github.com/pbnjay/memory
|
||||
GOOS=windows GOARCH=386 go build -o getMemory.exe getMemory.go
|
||||
GOOS=linux GOARCH=386 go build -o getMemory-linux getMemory.go
|
||||
GOOS=darwin GOARCH=386 go build -o getMemory-osx getMemory.go
|
||||
```
|
||||
|
||||
Alternatively create the Dockerfile:
|
||||
|
||||
```sh
|
||||
docker create -t getmemory .
|
||||
```
|
||||
|
||||
That will spit out an image id. You can then run:
|
||||
|
||||
```sh
|
||||
docker cp 2a5d878266d8d0789c0941707bc6a714e6b3986b67999059ba782dc18e7063de:/app/getMemory.exe .
|
||||
docker cp 2a5d878266d8d0789c0941707bc6a714e6b3986b67999059ba782dc18e7063de:/app/getMemory-linux .
|
||||
docker cp 2a5d878266d8d0789c0941707bc6a714e6b3986b67999059ba782dc18e7063de:/app/getMemory-osx .
|
||||
```
|
||||
|
||||
Alternatively just run:
|
||||
|
||||
```sh
|
||||
./generateBinary.sh
|
||||
// or
|
||||
./generateBinary.bat
|
||||
```
|
7
getMemory/generateBinary.bat
Normal file
7
getMemory/generateBinary.bat
Normal file
|
@ -0,0 +1,7 @@
|
|||
FOR /F "tokens=* USEBACKQ" %%F IN (`docker create -t getmemory`) DO (
|
||||
SET IMAGE_ID=%%F
|
||||
)
|
||||
|
||||
docker cp %IMAGE_ID%:/app/getMemory.exe .
|
||||
docker cp %IMAGE_ID%:/app/getMemory-linux .
|
||||
docker cp %IMAGE_ID%:/app/getMemory-osx .
|
5
getMemory/generateBinary.sh
Normal file
5
getMemory/generateBinary.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
IMAGE_ID=`docker create -t getmemory .`
|
||||
|
||||
docker cp ${IMAGE_ID}:/app/getMemory.exe .
|
||||
docker cp ${IMAGE_ID}:/app/getMemory-linux .
|
||||
docker cp ${IMAGE_ID}:/app/getMemory-osx .
|
10
getMemory/getMemory.go
Normal file
10
getMemory/getMemory.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pbnjay/memory"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(memory.TotalMemory())
|
||||
}
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
<groupId>com.atlauncher</groupId>
|
||||
<artifactId>atlauncher</artifactId>
|
||||
<name>ATLauncher</name>
|
||||
<version>3.2.6.1</version>
|
||||
<version>3.2.7.0</version>
|
||||
<organization>
|
||||
<name>ATLauncher</name>
|
||||
<url>http://www.github.com/ATLauncher/</url>
|
||||
|
|
|
@ -343,18 +343,17 @@ public class App {
|
|||
|
||||
LogManager.info("64 Bit Java: " + Utils.is64Bit());
|
||||
|
||||
if (Utils.isSystemJavaNewerThanJava8()) {
|
||||
LogManager.warn(
|
||||
"You're using a newer version of Java than Java 8! ATLauncher is only compatable with Java 8");
|
||||
String[] options = { "Close" };
|
||||
if (Utils.isMinecraftJavaNewerThanJava8()) {
|
||||
LogManager.warn("You're using a newer version of Java than Java 8! Modpacks may not launch.");
|
||||
String[] options = { "Ok" };
|
||||
JOptionPane.showOptionDialog(null, HTMLUtils.centerParagraph(
|
||||
"You're using a newer version of Java than Java 8! ATLauncher is only compatable with Java 8. Please uninstall Java and install Java 8"),
|
||||
"Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]);
|
||||
System.exit(0);
|
||||
"You're using a newer version of Java than Java 8! Modpacks may not work with Java 8. Please install Java 8 then set it in the launchers java settings"),
|
||||
"Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
|
||||
}
|
||||
|
||||
LogManager.info("RAM Available: " + Utils.getMaximumRam() + "MB");
|
||||
|
||||
int maxRam = Utils.getMaximumRam();
|
||||
LogManager.info("RAM Available: " + (maxRam == 0 ? "Unknown" : maxRam + "MB"));
|
||||
|
||||
LogManager.info("Launcher Directory: " + settings.getBaseDir());
|
||||
LogManager.info("Using Theme: " + THEME);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package com.atlauncher.data;
|
||||
|
||||
public class Constants {
|
||||
public static final LauncherVersion VERSION = new LauncherVersion(3, 2, 6, 1);
|
||||
public static final LauncherVersion VERSION = new LauncherVersion(3, 2, 7, 0);
|
||||
public static final String LAUNCHER_NAME = "ATLauncher";
|
||||
public static final String API_BASE_URL = "https://api.atlauncher.com/v1/launcher/";
|
||||
public static final String PASTE_CHECK_URL = "https://paste.atlauncher.com";
|
||||
|
|
|
@ -151,9 +151,9 @@ public class Settings {
|
|||
private List<Account> accounts = new ArrayList<Account>(); // Accounts in the Launcher
|
||||
private List<MinecraftServer> checkingServers = new ArrayList<MinecraftServer>();
|
||||
// Directories and Files for the Launcher
|
||||
private File baseDir, backupsDir, configsDir, themesDir, jsonDir, versionsDir, imagesDir, skinsDir, jarsDir,
|
||||
commonConfigsDir, assetsDir, resourcesDir, librariesDir, gameLibrariesDir, loadersDir, languagesDir,
|
||||
downloadsDir, usersDownloadsFolder, instancesDir, serversDir, tempDir, failedDownloadsDir,
|
||||
private File baseDir, backupsDir, configsDir, themesDir, jsonDir, versionsDir, imagesDir, skinsDir, toolsDir,
|
||||
jarsDir, commonConfigsDir, assetsDir, resourcesDir, librariesDir, gameLibrariesDir, loadersDir,
|
||||
languagesDir, downloadsDir, usersDownloadsFolder, instancesDir, serversDir, tempDir, failedDownloadsDir,
|
||||
instancesDataFile, checkingServersFile, userDataFile, propertiesFile, logsDir;
|
||||
// Launcher Settings
|
||||
private JFrame parent; // Parent JFrame of the actual Launcher
|
||||
|
@ -204,6 +204,7 @@ public class Settings {
|
|||
versionsDir = new File(configsDir, "Versions");
|
||||
imagesDir = new File(configsDir, "Images");
|
||||
skinsDir = new File(imagesDir, "Skins");
|
||||
toolsDir = new File(configsDir, "Tools");
|
||||
jarsDir = new File(configsDir, "Jars");
|
||||
commonConfigsDir = new File(configsDir, "Common");
|
||||
resourcesDir = new File(configsDir, "Resources");
|
||||
|
@ -838,9 +839,9 @@ public class Settings {
|
|||
* Checks the directory to make sure all the necessary folders are there
|
||||
*/
|
||||
private void checkFolders() {
|
||||
File[] files = { backupsDir, configsDir, themesDir, jsonDir, commonConfigsDir, imagesDir, skinsDir, jarsDir,
|
||||
assetsDir, librariesDir, gameLibrariesDir, loadersDir, languagesDir, downloadsDir, instancesDir,
|
||||
serversDir, tempDir, failedDownloadsDir, logsDir };
|
||||
File[] files = { backupsDir, configsDir, themesDir, jsonDir, commonConfigsDir, imagesDir, skinsDir, toolsDir,
|
||||
jarsDir, assetsDir, librariesDir, gameLibrariesDir, loadersDir, languagesDir, downloadsDir,
|
||||
instancesDir, serversDir, tempDir, failedDownloadsDir, logsDir };
|
||||
for (File file : files) {
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
|
@ -935,6 +936,15 @@ public class Settings {
|
|||
return this.skinsDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tools directory
|
||||
*
|
||||
* @return File object for the tools directory
|
||||
*/
|
||||
public File getToolsDir() {
|
||||
return this.toolsDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the jars directory
|
||||
*
|
||||
|
|
|
@ -44,8 +44,6 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -472,28 +470,24 @@ public class Utils {
|
|||
public static int getSystemRam() {
|
||||
long ramm = 0;
|
||||
int ram = 0;
|
||||
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||
App.settings.getToolsDir() + File.separator + "getMemory.exe");
|
||||
processBuilder.directory(App.settings.getToolsDir().getAbsoluteFile());
|
||||
processBuilder.redirectErrorStream(true);
|
||||
|
||||
try {
|
||||
Method m = operatingSystemMXBean.getClass().getDeclaredMethod("getTotalPhysicalMemorySize");
|
||||
m.setAccessible(true);
|
||||
Object value = m.invoke(operatingSystemMXBean);
|
||||
if (value != null) {
|
||||
ramm = Long.parseLong(value.toString());
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
try {
|
||||
ramm = Long.parseLong(br.readLine());
|
||||
ram = (int) (ramm / 1048576);
|
||||
} else {
|
||||
ram = 1024;
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
LogManager.logStackTrace(e);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
return ram;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue