I'm trying add a Java installation on my Yocto build. I would like to run on my embedded system a Java application I developed but I can't correctly install Java.
When I try to run java I get the following:
./java: No such file or directory
I googled for a solution and found that I need to install libc6 32 bit version.
I proceeded to modify my local.conf file as following:
MACHINE ??= "intel-corei7-64"
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
DISTRO ?= "poky"
PACKAGE_CLASSES ?= "package_rpm"
SDKMACHINE ?= "x86_64"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
STOPTASKS,/tmp,100M,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K \
ABORT,/tmp,10M,1K"
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
CONF_VERSION = "1"
CORE_IMAGE_EXTRA_INSTALL = " lib32-glibc"
CORE_IMAGE_EXTRA_INSTALL += "opencv opencv-samples libopencv-core-dev libopencv-highgui-dev libopencv-imgproc-dev libopencv-objdetect-dev libopencv-ml-dev"
But i get this error:
Build Configuration:
BB_VERSION = "1.32.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal-4.8"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "intel-corei7-64"
DISTRO = "poky"
DISTRO_VERSION = "2.2.1"
TUNE_FEATURES = "m64 corei7"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "morty:924e576b8930fd2268d85f0b151e5f68a3c2afce"
meta-intel = "morty:6add41510412ca196efb3e4f949d403a8b6f35d7"
meta-oe = "morty:fe5c83312de11e80b85680ef237f8acb04b4b26e"
meta-intel-realsense = "morty:2c0dfe9690d2871214fba9c1c32980a5eb89a421"
Initialising tasks: 100% |#####################################################################################################################################################################################################| Time: 0:00:22
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: rmc-1.0-r0 do_package: QA Issue: rmc: Files/directories were installed but not shipped in any package:
/usr/lib
/usr/lib/librmclefi.a
/usr/lib/librsmpefi.a
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
rmc: 3 installed and not shipped files. [installed-vs-shipped]
ERROR: rmc-1.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: rmc-1.0-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in: /home/dalben/WorkingBuild/poky/filec/tmp/work/corei7-64-poky-linux/rmc/1.0-r0/temp/log.do_package.16424
ERROR: Task (/home/dalben/WorkingBuild/poky/meta-intel/common/recipes-bsp/rmc/rmc.bb:do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2954 tasks of which 2937 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/dalben/WorkingBuild/poky/meta-intel/common/recipes-bsp/rmc/rmc.bb:do_package
Summary: There were 3 ERROR messages shown, returning a non-zero exit code.
Any help is appreciated.
EDIT: Updated question here.
For your information, you will need to do a lot of work in putting Java into your image.
Your current image does not have any java related programs installed since I do not see meta-java in your compile process.
CORE_IMAGE_EXTRA_INSTALL is restricted to OE Core images; So if you have your own image recipe, the variable will does not work unless you inherit core-image.bbclass
Here is an example on putting "openjdk-7-jre" to the image: http://wiki.hioproject.org/index.php?title=OpenHAB:_WeMo_Switch
The key elements are: meta-java, meta-oracle-java .
You will need to add them to your conf/bblayers.conf
BBLAYERS = " \
${BSPDIR}/sources/meta-java \
${BSPDIR}/sources/meta-oracle-java \
"
In conf/local.conf, add this line to install openjdk-7-jre.
IMAGE_INSTALL_append = " openjdk-7-jre "
To add more on what you need, check on https://layers.openembedded.org/layerindex/branch/master/layers/
Related
I'm using the MaxEntVariableSelection package and repeatedly getting the following error when trying to execute VariableSelection even after setting all the things as explained in MaxentVAriableSelection Vignette. Any help to skip this error is much appreciated.
These occurrence/background CSV files do not contain NAs or Numbering column before the "species" column and have SWD format. All the files, raster layers and maxent.jar set in the same working directory. Raster layers are separate and in .asc format.
MaxentVariableSelection::VariableSelection(maxent="C:/Users/Piyali/Desktop/msc_paper/R_SDM/maxent.jar",
outdir="C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2",
gridfolder="/Users/Piyali/Desktop/msc_paper/R_SDM/30sclippedascii",
occurrencelocations="C:/Users/Piyali/Desktop/msc_paper/R_SDM/xocc_all.csv",
backgroundlocations="C:/Users/Piyali/Desktop/msc_paper/R_SDM/xbg_all.csv",
additionalargs="nolinear noquadratic noproduct nothreshold noautofeature",
contributionthreshold=5,
correlationthreshold=0.9,
betamultiplier=seq(2,6,0.5))
Error in .local(.Object, ...) :
In addition: Warning messages:
1: In system(paste("java -jar", maxent, "-o", outdir, "-j", gridfolder, :
running command 'java -jar C:/Users/Piyali/Desktop/msc_paper/R_SDM/maxent.jar -o C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2 -j /Users/Piyali/Desktop/msc_paper/R_SDM/30sclippedascii/ -s C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2/xocc_all.csv_VariableSubset.csv -e C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2/xbg_all.csv_VariableSubset.csv plots=false writeplotdata=false visible=false autorun=true randomseed=true writebackgroundpredictions=false replicates=10 replicatetype=subsample randomtestpoints=50 redoifexists writemess=false writeclampgrid=false askoverwrite=false pictures=false outputgrids=false -b 2 nolinear noquadratic noproduct nothreshold noautofeature' had status 1
2: In system(paste("java -jar", maxent, "-o", outdir, "-j", gridfolder, :
running command 'java -jar C:/Users/Piyali/Desktop/msc_paper/R_SDM/maxent.jar -o C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2 -j /Users/Piyali/Desktop/msc_paper/R_SDM/30sclippedascii/ -s C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2/xocc_all.csv_VariableSubset.csv -e C:/Users/Piyali/Desktop/msc_paper/R_SDM/outputtest2/xbg_all.csv_VariableSubset.csv plots=false writeplotdata=false visible=false autorun=true randomseed=true writebackgroundpredictions=false redoifexists writemess=false writeclampgrid=false askoverwrite=false pictures=false outputformat=raw -b 2 nolinear noquadratic noproduct nothreshold noautofeature' had status 1
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file. (file does not exist)
If anyone finds this error in the future, check whether the column names of the variables in occurrence/background CSV files are exactly similar to the names of raster layers you have provided.
I am trying to install java using powershell Invoke-WebRequest command on packer instance however, I am getting below error;
Cannot index into a null array.
At line:1 char:94
+ ... content | %{[regex]::matches($_, '(?:<a title="Download Java software ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Command;
[Net.ServicePointManager]::SecurityProtocol = "tls12"
$URL = (Invoke-WebRequest -UseBasicParsing https://www.java.com/en/download/manual.jsp).Content | %{[regex]::matches($_, '(?:<a title="Download Java software for Windows .64-bit." href=")(.*)(?:">)').Groups[1].Value}
Invoke-WebRequest -UseBasicParsing -OutFile jre8.exe $URL
Start-Process .\jre8.exe '/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0' -wait
Few weeks ago I was able to run it successfully but since yesterday getting the above error.
Any advise?
Thanks.
This happens, as there is no such as string as Download Java software for Windows on the web page. Since the regex doesn't match anything, Groups member doesn't exist and you'll get an error about trying to index into a non-existing member.
Either use a web browser's View Source command, or save the content on a text file and view it with Notepad like so,
$cc = (Invoke-WebRequest -UseBasicParsing https://www.java.com/en/download/manual.jsp).Content
Set-Content -Path c:\temp\javapage.txt -Value $cc
notepad c:\temp\javapage.txt
The page loads a bunch of Javascript that generates the actual page seen on a browser.
I'm having a lot of trouble installing Java on my Poky Linux system. I'm building my system using Yocto with the following configuration:
local.conf
MACHINE ??= "intel-corei7-64"
DISTRO ?= "poky"
PACKAGE_CLASSES ?= "package_rpm"
SDKMACHINE ?= "x86_64"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
STOPTASKS,/tmp,100M,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K \
ABORT,/tmp,10M,1K"
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
CONF_VERSION = "1"
BB_NUMBER_THREADS = '12'
PARALLEL_MAKE = '-j 12'
# Java installation
CORE_IMAGE_EXTRA_INSTALL += "gtkperf libxslt"
IMAGE_INSTALL_append = " openjdk-7-jre "
LICENSE_FLAGS_WHITELIST += "oracle_java"
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"
PREFERRED_VERSION_xserver-nodm-init = "1.0"
# OpenCV installation
CORE_IMAGE_EXTRA_INSTALL += "opencv opencv-samples libopencv-core-dev libopencv-highgui-dev libopencv-imgproc-dev libopencv-objdetect-dev libopencv-ml-dev"
bblayers.conf
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
$HOME/poky/meta \
$HOME/poky/meta-poky \
$HOME/poky/meta-yocto-bsp \
$HOME/poky/meta-intel \
$HOME/poky/meta-openembedded/meta-oe \
$HOME/poky/meta-intel-realsense \
$HOME/poky/meta-java \
$HOME/poky/meta-oracle-java \
"
I need to use morty branch since I'm using Intel Realsense layer which is only compatible with 4.8 kernel
Build Configuration:
BB_VERSION = "1.32.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "CentOSLinux-7.3.1611"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "intel-corei7-64"
DISTRO = "poky"
DISTRO_VERSION = "2.2.1"
TUNE_FEATURES = "m64 corei7"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "morty:924e576b8930fd2268d85f0b151e5f68a3c2afce"
meta-intel = "morty:6add41510412ca196efb3e4f949d403a8b6f35d7"
meta-oe = "morty:fe5c83312de11e80b85680ef237f8acb04b4b26e"
meta-intel-realsense = "morty:2c0dfe9690d2871214fba9c1c32980a5eb89a421"
meta-java = "master:67e48693501bddb80745b9735b7b3d4d28dce9a1"
meta-oracle-java = "morty:f44365f02b283c3fb362dc99e2e996d3f11e356e"
I get the following error:
ERROR: openjdk-7-jre-99b00-2.6.5-r6.1 do_compile: oe_runmake failed
ERROR: openjdk-7-jre-99b00-2.6.5-r6.1 do_compile: Function failed: do_compile (log file is located at /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780)
ERROR: Logfile of failure stored in: /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780
Log data follows:
and then several hundreds lines of error log.
Any help is appreciated.
EDIT: From the log.do_compile file
ERROR: oe_runmake failed
In file included from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/constantPoolOop.hpp:29:0,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/methodOop.hpp:33,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/runtime/frame.hpp:29,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/prims/jvmtiExport.hpp:33,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/runtime/thread.hpp:32,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/os/linux/vm/thread_linux.inline.hpp:30,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/memory/resourceArea.hpp:30,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp:29,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/classLoader.hpp:28,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp:29,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciEnv.hpp:30,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciUtilities.hpp:28,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciNullObject.hpp:30,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciConstant.hpp:29,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/precompiled/precompiled.hpp:36:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp: At global scope:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp:189:42: error: left operand of shift expression '(-1 << 28)' is negative [-fpermissive]
option_bits_mask = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
~~~~~~^~~~~~~~~~~~~~~~~~~
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp:189:104: error: enumerator value for 'option_bits_mask' is not an integer constant
option_bits_mask = ~(((-1) << tos_state_shift) | (field_index_mask | parameter_size_mask))
^
In file included from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciEnv.hpp:32:0,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciUtilities.hpp:28,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciNullObject.hpp:30,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/ci/ciConstant.hpp:29,
from /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/precompiled/precompiled.hpp:36:
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/code/dependencies.hpp:169:59: error: left operand of shift expression '(-1 << 1)' is negative [-fpermissive]
all_types = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
~~~~~~^~~~~~~~~~~~~~
/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/src/share/vm/code/dependencies.hpp:169:72: error: enumerator value for 'all_types' is not an integer constant
all_types = ((1 << TYPE_LIMIT) - 1) & ((-1) << FIRST_TYPE),
^
gmake[7]: *** [precompiled.hpp.gch] Error 1
gmake[7]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir/linux_amd64_zero/product'
gmake[6]: *** [the_vm] Error 2
gmake[6]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir/linux_amd64_zero/product'
gmake[5]: *** [productzero] Error 2
gmake[5]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk.build/hotspot/outputdir'
gmake[4]: *** [generic_buildzero] Error 2
gmake[4]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/make'
gmake[3]: *** [productzero] Error 2
gmake[3]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk/hotspot/make'
gmake[2]: *** [hotspot-build] Error 2
gmake[2]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk'
gmake[1]: *** [build_product_image] Error 2
gmake[1]: Leaving directory `/home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/icedtea-2.6.5/build/openjdk'
make: *** [Makefile:2451: stamps/icedtea.stamp] Error 2
ERROR: Function failed: do_compile (log file is located at /home/dalben/NewBuild/poky/filec/tmp/work/corei7-64-poky-linux/openjdk-7-jre/99b00-2.6.5-r6.1/temp/log.do_compile.3780)
I manually patched the files generating those error and builded the image. It gave a new error but successfully wrote the image. Java in installed:
root#intel-corei7-64:~# java -version
java version "1.7.0_99"
OpenJDK Runtime Environment (IcedTea 2.6.5) (99b00-2.6.5)
OpenJDK 64-Bit Zero VM (build 24.95-b01, interpreted mode)
The solution is either:
Manually patch openjdk following
this
Use a newer version of openjdk. This can be achived using a more
recent commit for the meta-java repository or setting a newer
preferred version in the local.conf.
EDIT: Added guide link.
Guide
Since I'm using this image in an OpenSource project I made a little guide on how to overcome the problems I had during the building process.
The guide can be found here.
UPDATE: I upgraded the JRE and JDK version. The new guide can be found here. For the bravest among you there's also an installer script.
Chef supports execution as non-root user:
https://docs.chef.io/ctl_chef_client.html#run-as-non-root-user
But if the Chef recipe requires action with root access, then it will not work.
Does one of the Chef recipe to install Java support non-root installation? I didn't find reply in their documentation.
https://supermarket.chef.io/cookbooks/java, with java_home attribute value set to user accessible directory then it should be good.
In general most community cookbooks expect to run as root, so you'll likely have to write your own.
I've been able to install java as non-root user by using following code in recipes / default.rb:
arch = node['java']['arch']
jdk_version = node['java']['jdk_version']
tarball_url = node['java']['jdk'][jdk_version][arch]['url']
tarball_checksum = node['java']['jdk'][jdk_version][arch]['checksum']
bin_cmds = []
java_home = node['java']['java_home']
java_ark 'jdk' do
url tarball_url
checksum tarball_checksum
bin_cmds bin_cmds
app_home java_home
owner node['current_user']
action :install
end
And in attributes / default.rb file:
set['java']['jdk_version'] = '7'
set['java']['java_home'] = "/home/jpmat/jdk#{node['java']['jdk_version']}"
set['java']['oracle']['accept_oracle_download_terms'] = 'true'
I'm working on a configuration script for a JNI wrapper. One of the configuration parameters is the path to jni.h. What's a good quick-and-dirty Autoconf test for whether this parameter is set correctly for C++ compilation? You can assume you're running on Linux and g++ is available.
Alternatively, is there a way to get javah (or a supporting tool) to give me this path directly?
Then there is the easy way: http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html
Sometimes it is best to just use the standard recipies.
Checking for headers is easy; just use AC_CHECK_HEADER. If it's in a weird place (i.e., one the compiler doesn't know about), it's entirely reasonable to expect users to set CPPFLAGS.
The hard part is actually locating libjvm. You typically don't want to link with this; but you may want to default to a location to dlopen it from if JAVA_HOME is not set at run time.
But I don't have a better solution than requiring that JAVA_HOME be set at configure time. There's just too much variation in how this stuff is deployed across various OSes (even just Linux distributions). This is what I do:
AC_CHECK_HEADER([jni.h], [have_jni=yes])
AC_ARG_VAR([JAVA_HOME], [Java Runtime Environment (JRE) location])
AC_ARG_ENABLE([java-feature],
[AC_HELP_STRING([--disable-java-feature],
[disable Java feature])])
case $target_cpu in
x86_64) JVM_ARCH=amd64 ;;
i?86) JVM_ARCH=i386 ;;
*) JVM_ARCH=$target_cpu ;;
esac
AC_SUBST([JVM_ARCH])
AS_IF([test X$enable_java_feature != Xno],
[AS_IF([test X$have_jni != Xyes],
[AC_MSG_FAILURE([The Java Native Interface is required for Java feature.])])
AS_IF([test -z "$JAVA_HOME"],
[AC_MSG_WARN([JAVA_HOME has not been set. JAVA_HOME must be set at run time to locate libjvm.])],
[save_LDFLAGS=$LDFLAGS
LDFLAGS="-L$JAVA_HOME/lib/$JVM_ARCH/client -L$JAVA_HOME/lib/$JVM_ARCH/server $LDFLAGS"
AC_CHECK_LIB([jvm], [JNI_CreateJavaVM], [LIBS=$LIBS],
[AC_MSG_WARN([no libjvm found at JAVA_HOME])])
LDFLAGS=$save_LDFLAGS
])])
FYI - the patch below against the latest ax_jni_include_dir.m4 works for me on Macos 11.1.
--- a/m4/ax_jni_include_dir.m4
+++ b/m4/ax_jni_include_dir.m4
## -73,13 +73,19 ## fi
case "$host_os" in
darwin*) # Apple Java headers are inside the Xcode bundle.
- macos_version=$(sw_vers -productVersion | sed -n -e 's/^#<:#0-9#:>#
*.\(#<:#0-9#:>#*\).#<:#0-9#:>#*/\1/p')
- if #<:# "$macos_version" -gt "7" #:>#; then
- _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
- _JINC="$_JTOPDIR/Headers"
+ major_macos_version=$(sw_vers -productVersion | sed -n -e 's/^\(#<:#0-9#:>#*\).#<:#0-9#:>#*.#<:#0-9#:>#*/\1/p')
+ if #<:# "$major_macos_version" -gt "10" #:>#; then
+ _JTOPDIR="$(/usr/libexec/java_home)"
+ _JINC="$_JTOPDIR/include"
else
- _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
- _JINC="$_JTOPDIR/Headers"
+ macos_version=$(sw_vers -productVersion | sed -n -e 's/^#<:#0-9#:>#*.\(#<:#0-9#:>#*\).#<:#0-9#:>#*/\1/p')
+ if #<:# "$macos_version" -gt "7" #:>#; then
+ _JTOPDIR="$(xcrun --show-sdk-path)/System/Library/Frameworks/JavaVM.framework"
+ _JINC="$_JTOPDIR/Headers"
+ else
+ _JTOPDIR="/System/Library/Frameworks/JavaVM.framework"
+ _JINC="$_JTOPDIR/Headers"
+ fi
fi
;;
*) _JINC="$_JTOPDIR/include";;