Picked up _JAVA_OPTIONS: -Xmx256M - java

While running every program i am getting this message Picked up _JAVA_OPTIONS: -Xmx256M on console in eclipse without output.
I already tried related answers but none of them working in my case and I am not using _JAVA_OPTIONS variable in environment variable.
runtime error:
Picked up _JAVA_OPTIONS: -Xmx256M
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [util.c:840]

The message "Picked up _JAVA_OPTIONS" implies that the Java runtime has found this setting in your environment variables. The solution depends on which operating system you are running. But assuming it is Windows, there are two possibilities:
The most likely is that it is picking it up from the System or User environment. Try opening and command prompt and typing
echo %_JAVA_OPTIONS%
If you see "-Xmx256M", then that's where it is coming from. Hit the start button and search for "Edit the system environment" variables. On the "Advanced" tab, click the "Environment Variables..." button at the bottom. You'll find the _JAVA_OPTIONS variable in either the System variables or the User variables (or both!). Delete or change to suit.
The other possiblity is that your Java programs are being executed via a script. Look at the shortcuts' properties (or however you start the programs) to see if they are directly referencing a java ".exe" executable, or if they are using a script. Alternatively, in your command prompt type
where java
And check to see if this is a true .exe file or a script. It's possible that the _JAVA_OPTIONS variable is hidden in there.

If Using Ubuntu 16.04,
Check etc/profile there you may find _JAVA_OPTIONS: -Xmx256M set.
That's a file where environment variables are set for the whole. I assume you are facing this message for every java application you run. Although there are other ways to set environment variables.
This link ubuntu-environmentvariables describes them, you can check them and try to see where have you set this environment variable. It will exactly of this sort Picked up _JAVA_OPTIONS: -Xmx256M.
Hope it helps. I faced the same issue and detected in the profile document mentioned above.

Go to System Environment Variables
check for JAVA_OPTIONS under variables
delete or update based on your requirement
i got the value as 1024 i modified to 16384
-Xms1024m -Xmx16384m

Related

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on

Whenever I execute java code on intellij on kali, or type java --version in command line
I get this message
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true.
I googled it and found this link that is exactly the same situation as me,
but what I understand is that it's an information not error and I can unset _JAVA_OPTIONS environmental variable.
What I'm asking for is that deleting this environmental variable will not cause any harm?
I read in the above link that If you remove that variable, information will be gone.
I didn't understand is that mean any damage or he just said that the message will gone!
And finally how to delete or unset this _JAVA_OPTIONS variable?
Update :
When I unset this variable by these commands
_SILENT_JAVA_OPTIONS="$_JAVA_OPTIONS"
unset _JAVA_OPTIONS
alias java='java "$_SILENT_JAVA_OPTIONS"'
-referenced from this link, the second answer- the message is still appear but after the output of the java program instead of before the output as it was!

Picked up _JAVA_OPTIONS in kali linux

Each time i execute java code i get this message:Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
This problem has solution for windows os but i can't find any solution for linux os.
I found a solution to this problem, I lost a lot of time of course. I'm definitely not sure what creates this situation, in my case it happened after installing NetBeans and changing the text display settings, I turned on anti-aliasin.
These settings are defined in these configuration files, just remove them:
/etc/X11/Xsession.d/90kali-themes.conf
/etc/environment.d/95kali-themes.conf
Java Option disabling in terminal
if your using java11-jdk in linux this might be working for disabling the java option from displaying in terminal.
_SILENT_JAVA_OPTIONS="$_JAVA_OPTIONS" && unset _JAVA_OPTIONS && alias java='java "$_SILENT_JAVA_OPTIONS"'
This is not warning, it is information.
It literally says that some settings were picked up from _JAVA_OPTIONS environmental variable. It is used to configure some switches "globally" for every java application that will be run in given environment. You must have this set either on system or user level. If you remove that variable, information will be gone.
ON Kali Linux ANDROID STUDIO
This information comes because an environment variable called _JAVA_OPTIONS setup by default. I solved it by Unseating the variable.
**To unset the value of this variable, use unset _JAVA_OPTIONS.
After that Android Studio will no longer display the information and Android Studio will be able to build projects that were previously failing to build..

System.getenv("TEST_HOME") is returning null

I am working on a ubuntu 14.0.4 machine.
I exported a variable TEST_HOME in my .bashrc file using
export TEST_HOME=/home/dev/code/test
When I tried echo $TEST_HOME from terminal, it returned /home/dev/code/test
So far, so good.
When I try from Java code :
String value = System.getenv("TEST_HOME");
value is null.
Am I missing something here?
Mentioning the variable in .bashrc will work only for programs started from shell. For system wide environment variables mention it in /etc/environment.
Refer Ubuntu Environment variables
.bashrc would set environment variable only for bash shell. To set it system wide set it in /etc/environment file.
Since you are using eclipse, and it does not run within bash shell, it is not getting the variable you are setting. If you run your programme using java command line in your terminal then it should get it.
Setting variable in /etc/environment would make it available to eclipse. You will need to restart your machine once you update /etc/environment.

Do I need to restart my system after setting JAVA in system environment's path variable?

I did the following steps but java does not seem to be working for me, do I need to restart my system if yes then why?
1. Right click My Computer->Advence Option->Environment Varibles->System Variables
2. variable : Path->Edit
3. Copy your jdk bin directory i.e.C:\Program Files\Java\jdk1.7.0_51\bin
4. Paste it after putting a semi-colon(;) in value section
i am getting below error while running java in cmd
C:\Users\User>java -version
Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
No, but you will need to close and recreate any cmd windows, running java programs, or the like.
To check it's correct, open a new cmd window and type set -> review the information for PATH and JAVA_HOME.
You should set two things:
JAVA_HOME
PATH
The first lies under the "User variables for [your user name]" section. Add the JAVA_HOME variable and set it to where your jdk is installed. i.e. C:\Program Files\Java\jdk1.7.0_51\
The second lies under the "System variables" section. You should find the "path" variable, and edit it. Then, append ";%JAVA_HOME%\bin" (minus the quotes) to the end of the path variable.
After you have done this, save the variables and close that window clicking the "ok" button. Close down all instances of the command prompt (and any IDE you may be developing with such as Eclipse or NetBeans), and reopen one command prompt. Then, if you would like to test whether or not your changes worked and are in effect, try the following:
echo %JAVA_HOME%
This should output where you set your java home variable to.
echo %PATH%
At the end of what is output, you should see your java home\bin addition to the path variable
java -version
If you can run this command from the command line, it means that your environment was set up correctly and java is now in your path.
Not necessary. Quit and Open the command prompt again (if any) that runs the java process and type java -version to check if it installed successfully.
If you are using mac, source ~/.bashrc or source ~/.zshrc should refresh your environmental variable. No need to re-start the terminal even.
No, you don't need to restart your system.
However, you have to restart your command prompt application to update the changes done on Environment variables.
NO.
You don't need to restart the system, but just the application like cmd or any IDE you are using for java development (i.e Eclipse) need to restart.
And to confirm that the java path is set that you have mentioned in JAVA_HOME environment variable, you can open cmd and you can check with commands echo %JAVA_HOME% or echo %PATH%.
I reinstall the JDK and set the JAVA_HOME and PATH variable again. now it's working.
In my case under user variable section(for particularuser) JAVA_HOME set to jre not jdk path . I change it to JDK path , It worked for me
yes need to restart cmd prompt after env variable change

reading environment variables from java using Eclipse

Everywhere I search, it says you can get an environment variable by using System.getenv(str).
It's not working for me. Here's what I am doing:
OS : Mac OS x 10.7
Java 1.6.x
If I do export abc=/hello/ in my terminal and then echo $abc, it gives me the variable. If I close the terminal, reopen it again and do echo $abc, it's gone. To overcome this, I edited my .bash_profile file and inserted export abc=/hello/. Close the terminal, do echo $abc and it works. So I understood that the env variable is permanent now.
Now if in my java console app, I print System.getenv("abc"), it returns null. What am I missing?
The reason that you needed to put the export in your .bash_profile is that setting environment variables in a shell only persist the variables in that shell, and - since you used export - to children of that shell, or in other words, other programs launched by that shell.
If you're running your java code from Eclipse, and you launch Eclipse from a shell with your environment variables set, then your program should see the added environment variables. To launch Eclipse from the shell, you'll need to use the OS X open command:
$ open /Applications/eclipse/Eclipse.app
Alternately, you can set the environment variables within your Eclipse project, and you'll need to do this if you're not launching Eclipse from a shell with the proper environment. In the Run Configurations dialog, look for a tab named Environment. Here you'll find a table for adding environment variables that will be passed to your program.
It's better to add the environment variables to the Run Configuration since that way they'll always be available to your project. Your code doesn't actually care where the environment variables are coming from, and adding them to the project is simpler, and will work the same way on different platforms.
Of course, when you run your program outside Eclipse, you'll need to make sure that the same environment variables exist in the shell where you e.g. run java.
Eclipse does not use the system's env variables unless launched directly from the shell (which is how it is generally launched, by clicking its icon). In that case you will have to explicitly set the required env variables in the environment tab of the run configuration of the program.
I too faced The same issue , I resolved it this way.
Open Terminal
cd to the folder where eclipse.app is located E.g cd /Users/Shared/eclipse/jee-2020-09
Type open Eclipse.app/
Eclipse will now open and will be able to access the system environment variables as well.
Check it using the code:
System.getenv().forEach((k, v) -> {
System.out.println("ENV : " + k + ":" + v);
});

Categories