Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java check to launcher #635

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dweipert-3138720606
Copy link

So issues like these won't happen: #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 #615 #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
Copy link
Author

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

@tom-overton
Copy link
Collaborator

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.

@dweipert-3138720606
Copy link
Author

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.

Copy link
Collaborator

@tom-overton tom-overton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the changes on Windows today, and they don't work. Specifically, the 32 vs. 64-bit check doesn't work properly, and actually causes the batch file to exit early. However, I discovered a simple way of checking it:

@echo off

java -version 2>&1 | findstr /i "64-Bit" >nul:

if errorlevel 1 (
    echo 32-Bit 
) else (
    echo 64-Bit
)

echo Press any key to exit...
pause >nul

Could you incorporate something like this into the Windows launcher? It doesn't have to exactly match this; I'm mainly just asking you to use java -version 2>&1 | findstr /i "64-Bit" >nul: and then check the errorlevel.

launcher/launcher_MAC.command Show resolved Hide resolved
where java >nul 2>nul
if %errorlevel%==1 (
@echo Java is not installed.
exit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing with the exits in the Windows launcher too.

@tom-overton
Copy link
Collaborator

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.

@dweipert-3138720606
Copy link
Author

dweipert-3138720606 commented Jul 15, 2023

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.

@tom-overton
Copy link
Collaborator

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.

@dweipert-3138720606
Copy link
Author

dweipert-3138720606 commented Aug 27, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants