How to fix picked up _java_options listed on Linux?

3.4K    Asked by alexDuncan in Java , Asked on Oct 13, 2022

This issue is on Manjaro Deepin 15.9 linux DE. When I run java -version in terminal it outputs this:

Picked up _JAVA_OPTIONS:    
java version "11.0.2" 2019-01-15 LTS     
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)    
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
But if the command is run with sudo it outputs it normally without the Picked up _JAVA_OPTIONS: message !

I managed by placing unset JAVA_OPTIONS in /etc/environment , /etc/profile and ~.bashrc to remove the message from the terminal. But the message still shows up in Netbeans when I run a project.

Also I ran Netbeans as sudo just to check if it would show then and it didn’t. I tried removing some software from Linux which I didn’t need or believe was causing the message (because I read a few posts about software being an issue), but nothing changed.

Message not showing in sudo makes me believe maybe the root user doesn’t have something installed that the normal user has which is producing this message.

This message is visible in the live preview of Manjaro Deepin on bootable usb!

Answered by Ava Black

When you changed users with sudo it changed your environment as well, and apparently the picked up_JAVA_OPTIONS variable did not exist in the root user's environment. It also vanished when you removed that variable from your own environment. However, Netbeans can adjust the environment however it wants before creating a Java subprocess, and it is configured to add in this variable whether it was there or not. You should be able to configure Netbeans not to add the variable at all, but the exact steps to do so will depend on your Netbeans version.



Your Answer

Answer (1)

When you see a message like "Picked up _JAVA_OPTIONS" on Linux, it usually indicates that the _JAVA_OPTIONS environment variable has been set somewhere in your system, and Java is picking it up every time it runs. This variable can affect Java's behavior, sometimes causing unexpected issues. To fix or manage this, you can follow these steps:


1. Identify Where _JAVA_OPTIONS is Set

Check Shell Configuration Files

The _JAVA_OPTIONS variable could be set in one of the shell configuration files. Common files to check include:

~/.bashrc

~/.bash_profile

~/.profile

/etc/environment

/etc/profile

/etc/profile.d/*.sh

You can use grep to search for _JAVA_OPTIONS in these files. For example:

grep _JAVA_OPTIONS ~/.bashrc ~/.bash_profile ~/.profile /etc/environment /etc/profile /etc/profile.d/*.sh

Check for Global Environment Variables

It might also be set in the global environment variables. You can check for this with:



printenv | grep _JAVA_OPTIONS

2. Remove or Modify the _JAVA_OPTIONS Setting

Once you find where _JAVA_OPTIONS is set, you can either remove it or modify it as needed. Here are the steps for some common scenarios:

Removing from Shell Configuration Files

If you find _JAVA_OPTIONS in one of the user-specific shell configuration files (like ~/.bashrc or ~/.profile), you can open the file with a text editor and remove or comment out the line:

  nano ~/.bashrc

# Then find and remove or comment out the line like:

  # export _JAVA_OPTIONS="-Xmx512M"

After editing, make sure to reload the file or restart the terminal:

source ~/.bashrc

Removing from Global Environment Variables

  If _JAVA_OPTIONS is set in /etc/environment or /etc/profile, you'll need to edit those files with superuser privileges:
sudo nano /etc/environment

# Or

  sudo nano /etc/profile

Remove or comment out the line setting _JAVA_OPTIONS, then apply the changes by logging out and logging back in, or by sourcing the file if it’s not /etc/environment:

  source /etc/profile

3. Verify the Changes

To ensure _JAVA_OPTIONS is no longer being picked up, check the environment variables again:

  printenv | grep _JAVA_OPTIONS

If nothing is returned, the variable has been successfully unset.



4. (Optional) Set New Java Options

If you need to set new Java options, you can do so in a controlled manner by setting the _JAVA_OPTIONS variable directly in your shell session or in your shell configuration file:

export _JAVA_OPTIONS="-Xmx1024M"

To make this change permanent, add it to ~/.bashrc or another appropriate shell configuration file.

By following these steps, you should be able to manage the _JAVA_OPTIONS variable effectively on your Linux system, ensuring that Java behaves as expected.

2 Days

Interviews

Parent Categories