universal-pokemon-randomizer-zx icon indicating copy to clipboard operation
universal-pokemon-randomizer-zx copied to clipboard

Add java check to launcher

Open dweipert-3138720606 opened this issue 1 year ago • 7 comments

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.

dweipert-3138720606 avatar Jun 12 '23 13:06 dweipert-3138720606

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

dweipert-3138720606 avatar Jun 16 '23 08:06 dweipert-3138720606

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.

tom-overton avatar Jun 24 '23 08:06 tom-overton

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.

dweipert-3138720606 avatar Jun 27 '23 19:06 dweipert-3138720606

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.

tom-overton avatar Jul 05 '23 04:07 tom-overton

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.

dweipert-3138720606 avatar Jul 15 '23 13:07 dweipert-3138720606

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.

tom-overton avatar Jul 18 '23 07:07 tom-overton

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! :)

dweipert-3138720606 avatar Aug 27 '23 18:08 dweipert-3138720606