Java and virtual memory ulimit - java-7

I am trying to use java in an environment where the virtual memory is limited to 2GB by ulimit -v 2000000 but I get memory errors. Running java -version in this environment gives:
$ java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
No matter how low I set -Xmx, I cannot get java to run under this environment. However, if ulimit -v is set to 2.5GB, then I can set -Xmx to 250m, but no higher.
$ java -Xmx250m -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
$ java -Xmx251m -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)# An error report file with more information is saved as:
# ~/hs_err_pid12079.log
Is it possible to use java in an environment where ulimit is used to limit the virtual memory?

This is a well known giant bug in all available JVMs (oracle or openjdk, version 6,7,8). Reported here:
https://bugs.launchpad.net/ubuntu/+source/openjdk-7/+bug/1241926
https://bugs.openjdk.java.net/browse/JDK-8071445
Unfortunately without solution by the Java developers.
Solution: Play desperately with the various java options or stop using java and java based applications :-(

Related

Cannot connect to h2o in R under Ubuntu

base) stephen#stephen-Aspire-5250:~$ java --version
java 13.0.1 2019-10-15
Java(TM) SE Runtime Environment (build 13.0.1+9)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
(base) stephen#stephen-Aspire-5250:~$ find . -name h2o.jar
./R/x86_64-pc-linux-gnu-library/3.4/h2o/java/h2o.jar
then from R
> h2o.init()
H2O is not running yet, starting it now...
Error in .h2o.checkJava() :
Cannot find Java. Please install the latest JRE from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
I have a feeling conda is messing up the landscape, but don't know how to fix.
I started h2o from terminal with:
java -jar ~/R/x86_64-pc-linux-gnu-library/3.4/h2o/java/h2o.jar
and then the h2o.init() from R works. Still, don't why h2o cannot find java, which is on my PATH.
H2O gets its path to java runtime from JAVA_HOME environment variable, so make sure to set it properly for/from R if you have to use h2o.init() rather than system shell/bash (e.g. with java -Xmx1g -jar ./h2o.jar).
More info
After several years of experience with H2O in Ubuntu/Centos/RHEL I now start H2O only from bash (issuing richly parameterized commands at H2O docker container startup), rather than with R or python API functions (it led to all sorts of problems, such as using all server CPU cores that yielded huge performance degradation for the inexperienced users or exposing passwordless REST API with root file access over standard H2O port to the entire corporate network...).
As a side note, Java 13 is supported by latest H2O versions, but I would still recommend using LTS versions, currently 11, for security reasons. The same of course applies to Ubuntu itself.

Why cmd give error when we open uiautomatorviewer?

When I run the following command in the command prompt that time I am getting the following error.
Command: C:\Users\ob>uiautomatorviewer
Error:
-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Set your all android path properly.
Add variable in system environment as mention below.
ANDROID_SWT : C:\Users\chetan\AppData\Local\Android\Sdk\tools\lib\x86_64
ANDROID_HOME : C:\Users\chetan\AppData\Local\Android\Sdk
ANDROID_PLATFORM_TOOLS : C:\Users\chetan\AppData\Local\Android\Sdk\platform-tools
Add below mention Path in Path Variable in system environment.
C:\Program Files\Java\jdk\bin;
C:\Users\chetan\AppData\Local\Android\Sdk\tools\bin;
C:\Users\chetan\AppData\Local\Android\Sdk\tools;
C:\Users\chetan\AppData\Local\Android\Sdk\platform-tools;
C:\Program Files\nodejs\node_modules\npm\bin;
C:\Users\chetan\AppData\Local\Android\Sdk;
C:\Users\chetan\AppData\Local\Android\Sdk\tools\lib\x86_64\swt.jar;
Pre-Check - Verify the java Version installed in your system.
VERIFY - java -version
java version "1.8.0_221" Java(TM) SE Runtime Environment (build
1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
If this message appears that means you have JAVA 8 install and uiautomatorviewer only supports till JAVA 8.
So install JAVA 8 from here and if you already have JAVA install down grade it to JAVA 8

How to run sonarqube on NetBSD

According to the requirements document for sonarqube:
The only prerequisite for running SonarQube is to have Java (Oracle JRE 7 onwards or OpenJDK 7 onwards) installed on your machine.
I want now to use a NetBSD 7.0 machine to run a sonarqube server.
OpenJDK8 is installed:
openjdk version "1.8.0_77-internal"
OpenJDK Runtime Environment (build
1.8.0_77-internal-pkgsrc_1.8.77-b00)
OpenJDK 64-Bit Server VM (build 25.77-b00, mixed mode)
However, sonarqube is using wrapper, and that software does not support NetBSD (FreeBSD is supported, but this is not close enough to serve as a working substitute).
I already tried using linux emulation mode. But, having a NetBSD native java being started from a linux emulated wrapper is not giving a usable configuration for runtime environment (libc version clashes, et. al.).
And installing a linux native openjdk8 and get the complete setup running in emulation mode is also not to be recommended.
With sonarqube 4.x (long ago) I had used war distribution
and this worked OK. But with this new environment I hoped for being able to use newer versions of sonarqube.
Questions:
Is there a way to bypass wrapper and start sonarqube relying on java only?
Alternatively, is there a way to get a NetBSD version of wrapper?
Would I be better of dropping sonarqube alltogether,
given my target platform?
The version of Java Service Wrapper used by SonarQube does not support NetBSD. That's not as critical as for MSWindows. SonarQube can be easily started as a unix daemon without it. You just have to execute java -jar lib/sonar-application-{version}.jar from the installation directory.

Unexpected error in checking hadoop version

ubuntu#ubuntu:~$ hadoop -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
After running this command, I get this. Unable to crack the problem. Checked all the entries in /.bashrc file. Please help.

Unix: Same executable, different user: different executable version?

I'm being very confused by the following happening in my terminal:
my-computer:~$ which java
/usr/bin/java
my-computer:~$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
my-computer:~$ sudo su
Password:
my-computer:/Users/paulhabfast$ which java
/usr/bin/java
my-computer:/Users/paulhabfast$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Can anyone explain me what is going on?
The way I understand it so far is that when I switch from the current user to the root user, I'm being served a different executable?
I'm running Mac OSX 10.9, but I thought I had a pretty standard unix environment.
Is there any additional information I can give?
/usr/bin/java is a wrapper that looks at your environment variables, try env to see these variables, for example JAVA_HOME.

Resources