universal-pokemon-randomizer-zx
universal-pokemon-randomizer-zx copied to clipboard
Add java check to launcher
So issues like these won't happen: https://github.com/Ajarmar/universal-pokemon-randomizer-zx/issues/606
I also want to look into how to check whether java 32-bit is installed and report that as well, so issues like these https://github.com/Ajarmar/universal-pokemon-randomizer-zx/issues/615 https://github.com/Ajarmar/universal-pokemon-randomizer-zx/issues/608 happen less frequent. People just don't read the wiki that often.
I don't know whether the launcher_MAC.command
syntax is correct and have no way to check right now. I just assumed it's bash as well.
Added the 32/64-Bit check. As of yet I only tested the launcher_UNIX.sh
.
I used these links to find out how to do the checks for Windows: https://stackoverflow.com/questions/108439/how-do-i-get-the-result-of-a-command-in-a-variable-in-windows https://stackoverflow.com/questions/8756804/check-a-string-for-a-substring-in-a-batch-file-windows
Looks good, but I have one suggestion; can you check for the lack of "64-bit" in the output, rather than the presence of "32-bit"? From what I've seen, some 32-bit versions of Java don't list that they are 32-bit in their --version
output; they just don't say anything.
Good idea! I inverted the checks! :)
Still only tested it on linux though, because I have no easy access to Mac or Windows right now.
Also, I tried it on a Mac that never had Java installed, and calling java
in the command line actually makes this text come up:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
This is apparently enough for the first part of the script to pass. It still fails out, but it thinks that 32-bit Java is installed instead of no Java being installed. I think this is an acceptable issue, but if you have any good ideas on how to catch this case, feel free to incorporate them into your Mac launcher.
I'll see that I set up access to windows and macOs so I can test all launcher scripts. On linux at least the terminal doesn't close when you call exit. I thought for at least on a Mac it would be the same. I'll try out and test and get back to you.
On Windows and Mac, users don't use the launcher by opening them from the terminal/command prompt. They double-click on the scripts, and it will automatically open a terminal/command prompt window to run the script. If you call exit
in your script, then this new window will instantly close without giving them a chance to read it.
I finally got around to test each launcher on their respective systems.
For Mac, I added the exit buffers,
and for Windows I just used goto
to go to the end of the script.
On Mac, I also changed the java-version message to "Wrong Java version: No Java or Java 32-Bit instead of 64-Bit is installed.". So in the case of the prompt when no Java is installed, the error message at least reads correctly.
On Windows, the findstr
solution works great and the .bat
file as a whole feels like it works now! :)