☕Java Local Binary
In this tutorial we will explain how to install the java bin locally in a Windows environment.
Install the local Java binary allows you to have multiple versions of Java in a Windows environment without having to modify the system environment variables.
Step 1: Download the Binary First, you need to download the binary for the Java version you want to install. To do this, go to the official Oracle website and find the corresponding version. Download the JDK .zip file for the Windows version.
Step 2: Extract the File
Navigate to the location where the .tar.gz file was downloaded, then extract the content to a location of your choice. You might choose to create a folder named "Java" in your home directory and extract the content there.
Step 3: Access the Binary
The Java binary will be in the resulting folder, which will consist of various files and directories. If you've followed these steps, it should be named something like jre1.8.0_202
or jdk1.8.0_181
, with the version varying. Within this folder, you'll find another one called "bin." This is the folder containing the binaries that allow you to run Java locally. The two executables included in the binary are java.exe
and javaw.exe
(java.exe will execute the file with the Java console, while javaw.exe will execute the file without the visual Java console, hiding it).
Step 4: Using Local Java
Instead of changing your system's environment variables, all you need to do to use this local Java installation is refer directly to it when entering commands. For example, if you want to compile a Java file, the normal command would be "java TestFile.java." However, if you want to use the local Java, you need to specify the full path to your Java binary.
Instead of just "java," the command should look something like this:
In our case, it might look like this:
This will compile the file using the Java binary you extracted, not the one installed in the system's environment variables.
Step 5: Create a Batch File (.bat extension)
To avoid typing out the full path each time, you can create a batch file in the same directory where your .java files are located. This batch file can contain the complete command, so you only need to run the batch file to compile your Java files.
An example of a batch file for a Minecraft server USING the binary directly (locally)
might be:
-Xms1G -Xmx2G -jar spigot.jar nogui timeout 10 goto start
-Xms1G is the argument that sets the minimum amount of RAM allocated to your Minecraft server (in this case, 1 gigabyte).
-Xmx2G is the argument that sets the maximum amount of RAM your Minecraft server can use (in this case, 2 gigabytes).
goto start is used to restart the server in case of crashes, bugs, or restarts.
If the binary folder (jre1.8.0_202) is in the same folder as the Minecraft server, you can use the following code:
Since the binary is in the same folder as the server, Windows will use the dynamic path to find the file. This way, you don't have to specify the entire path, just the path starting from the folder where the batch file is located.
An example of a batch file for a Minecraft server NOT USING the binary directly (locally)
and using Windows environment variables could be:
Last updated