Software & AppsOperating SystemLinux

How To Run Java/Minecraft with Nvidia GPU on Ubuntu 18.04

Ubuntu 14

In this article, we will guide you through the process of running Java/Minecraft with an Nvidia GPU on Ubuntu 18.04. We will explore three different solutions, each with its own set of steps. These solutions include using Nvidia X Server Settings, a script, and environment variables. Let’s dive in!

Quick Answer

To run Java/Minecraft with an Nvidia GPU on Ubuntu 18.04, you have three solutions: using Nvidia X Server Settings, creating a script, or setting environment variables. Each solution has its own set of steps, but all aim to ensure that Java/Minecraft utilizes the power of your Nvidia GPU for improved performance and graphics.

Solution 1: Using Nvidia X Server Settings

Nvidia X Server Settings is a tool that comes with Nvidia’s proprietary drivers. It allows users to configure the Nvidia graphics card settings on a per-application basis.

Step 1: Open Nvidia X Server Settings

Launch the ‘NVIDIA X Server Settings’ window from your application menu.

Step 2: Create a New Profile

Under the drop-down menu for your Nvidia GPU, click on “Creating Application Profiles”. In the “Profiles” tab, click the green plus button to add a new profile. Name the profile as per your preference.

Step 3: Add Settings to the Profile

Add the following settings to your new profile:

  • GLAllowFXAAUsage=true: Enables Fast Approximate Anti-Aliasing (FXAA).
  • GLGSyncAllowed=true: Allows G-Sync, a technology that eliminates screen tearing.
  • GLShaderDiskCache=true: Enables shader disk cache, which can improve performance.
  • GLThreadedOptimizations=true: Enables multi-threaded optimizations, which can also improve performance.
  • GLSyncToVblank=true: Synchronizes the GPU’s actions to the vertical blanking interval, which can prevent screen tearing.

Save the profile by clicking the green plus button at the bottom of the window.

Step 4: Create a New Rule

Go to the “Rules” tab and add a new rule. In the “Rule Pattern” section, select “Always Applies” from the drop-down menu and type “Java” in the text entry field. In the “Rule Profile” section, select the profile you just created. Save the rule by clicking the green plus button at the bottom of the window.

Step 5: Save the Configuration

Save the configuration by clicking the disk icon with the green down arrow. This ensures that the settings are applied every time you run Java/Minecraft.

Solution 2: Using a Script

This solution involves creating a script that runs Java/Minecraft with the Nvidia GPU.

Step 1: Create a Script File

Create a script file at a desired location. For instance, you can create it in the Minecraft directory: ~/.minecraft/launch.sh.

Step 2: Write the Script

Copy and paste the following code into the script file:

#!/bin/bash
/usr/bin/prime-run /usr/bin/java "$@"

Here, /usr/bin/prime-run is a command that runs the following application with the Nvidia GPU. /usr/bin/java "$@" runs Java with any arguments passed to the script.

Step 3: Make the Script Executable

Make the script executable by running the following command in the terminal:

chmod +x ~/.minecraft/launch.sh

The chmod +x command changes the permissions of the file to make it executable.

Step 4: Change the Java Executable Path in Minecraft

Open the Minecraft launcher and go to the “Installations” tab. Click on “Edit” for the desired installation. In the “MORE OPTIONS” submenu, change the Java executable path to the script file you created.

Step 5: Launch the Game

Launch the game and check if it is using the Nvidia GPU by pressing F3 and looking for the GPU information in the debug menu.

Solution 3: Using Environment Variables

This solution involves setting environment variables that force Minecraft to use the Nvidia GPU.

Step 1: Install Nvidia’s Driver

Install Nvidia’s proprietary driver by running the following command in the terminal:

sudo apt install nvidia-driver

The sudo command runs the following command with administrative privileges. apt install installs the specified package, in this case, nvidia-driver.

Step 2: Reboot Your System

Reboot your system to ensure that the driver is properly loaded.

Step 3: Run Minecraft with Environment Variables

Run Minecraft with the following command:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia minecraft-launcher

Here, __NV_PRIME_RENDER_OFFLOAD=1 and __GLX_VENDOR_LIBRARY_NAME=nvidia are environment variables that tell the system to use the Nvidia GPU for rendering. minecraft-launcher is the command that launches Minecraft.

In conclusion, running Java/Minecraft with an Nvidia GPU on Ubuntu 18.04 can be achieved through various methods. Depending on your specific hardware and software configuration, one solution may work better than the others. It is recommended to try each solution and see which one works best for you. Happy gaming!

Can I run Java/Minecraft with an Nvidia GPU on Ubuntu 18.04?

Yes, you can run Java/Minecraft with an Nvidia GPU on Ubuntu 18.04 by following the solutions provided in this article.

What is Nvidia X Server Settings?

Nvidia X Server Settings is a tool that comes with Nvidia’s proprietary drivers. It allows users to configure the Nvidia graphics card settings on a per-application basis.

How do I open Nvidia X Server Settings?

You can open Nvidia X Server Settings by launching the ‘NVIDIA X Server Settings’ window from your application menu.

How do I create a new profile in Nvidia X Server Settings?

To create a new profile in Nvidia X Server Settings, click on "Creating Application Profiles" under the drop-down menu for your Nvidia GPU. In the "Profiles" tab, click the green plus button to add a new profile and name it as per your preference.

What settings should I add to the profile in Nvidia X Server Settings?

In the new profile, add the following settings: GLAllowFXAAUsage=true, GLGSyncAllowed=true, GLShaderDiskCache=true, GLThreadedOptimizations=true, and GLSyncToVblank=true. These settings can improve performance and prevent screen tearing.

How do I save the configuration in Nvidia X Server Settings?

To save the configuration in Nvidia X Server Settings, click the disk icon with the green down arrow. This ensures that the settings are applied every time you run Java/Minecraft.

How do I create a script to run Java/Minecraft with the Nvidia GPU?

To create a script, first create a file at a desired location (e.g., ~/.minecraft/launch.sh). Then, copy and paste the provided script code into the file. Make the script executable by running chmod +x ~/.minecraft/launch.sh in the terminal.

How do I change the Java executable path in Minecraft to use the script?

In the Minecraft launcher, go to the "Installations" tab, click on "Edit" for the desired installation, and in the "MORE OPTIONS" submenu, change the Java executable path to the script file you created.

How do I check if Minecraft is using the Nvidia GPU?

To check if Minecraft is using the Nvidia GPU, launch the game and press F3. Look for the GPU information in the debug menu.

What are the environment variables used to force Minecraft to use the Nvidia GPU?

The environment variables used are __NV_PRIME_RENDER_OFFLOAD=1 and __GLX_VENDOR_LIBRARY_NAME=nvidia. These variables tell the system to use the Nvidia GPU for rendering when launching Minecraft with the minecraft-launcher command.

Leave a Comment

Your email address will not be published. Required fields are marked *