I am trying to get apache ant 1.8 to work under CentOS. First, I had this error.
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Then I set the following variables according to this link:
Ant: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
It's not CentOS, but I did verify the paths exist except JAVA_HOME, so I set it according to this site:
https://serverfault.com/questions/50883/what-is-the-value-of-java-home-for-centos
Now I am getting the same error I did the first time. It does not matter which ant rule I use, I still get the same error.
[alpha:~]
[bullshark]% export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/
[alpha:~]
[bullshark]% export ANT_HOME=/usr/share/ant/
[alpha:~]
[bullshark]% export PATH=$PATH:$ANT_HOME/bin
[alpha:~]
[bullshark]% cd JRobo
[alpha:JRobo] on master
[bullshark]% ant clean-and-fat-jar
Picked up _JAVA_OPTIONS: -Xmx64m
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
[alpha:JRobo] on master
[bullshark]% cat /etc/redhat-release
CentOS release 6.3 (Final)
[alpha:JRobo] on master
[bullshark]%
You can clone him on CentOS if you want to try:
https://github.com/BullShark/JRobo
For Apache Ant 1.8 on CentOS:
http://www.jpackage.org/browser/rpm.php?jppversion=6.0&id=11867
For a package or manually:
https://ant.apache.org/bindownload.cgi?Preferred=ftp://apache.mirrors.pair.com/
Here are the steps required to get ant 1.8 installed on CentOS:
Download http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
Copy the tarball to your CentOS home folder (if it's not already there)
tar xvzf apache-ant-1.8.4-bin.tar.gz
sudo mv apache-ant-1.8.4 /opt/ant
Set ANT_HOME=/opt/ant
Add ‘export ANT_HOME=/opt/ant’ to /etc/profile
To verify that it worked, run:
ant -version
Related
I have an Amazon EC2 t3.medium instance on Linux.
I am trying to run Apache ni-fi on this instance and I need java.
When I check the JAVA_HOME default:
$ echo$JAVA_HOME
-bash: echo/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261-2.6.22.2.amzn2.0.2.x86_64: No such file or directory
Then, I downloaded java 1.8 by the following comamnds on terminal:
$ sudo yum install java-1.8.0-openjdk.x86_64
$ sudo update-alternatives --config java
(I selected 2 for java 1.8)
To find the location of my java file, I run them:
$ file $(which java)
/usr/bin/java: symbolic link to `/etc/alternatives/java'
$ file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java'
$ file /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.2.0, BuildID[sha1]=1b1c0fd721197a04f9bfc9b0891f1bd83a5f49d5, not stripped
I guess it is working properly. Then, I change JAVA_HOME from 1.7 to 1.8 by writing these commands on terminal for both ec2-user and root:
[root#ip-178-32-11-247 ~]# export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64"
[root#ip-178-32-11-247 ~]# PATH=$JAVA_HOME/bin:$PATH
In advance, I have setup nifi on root. And in nifi-1.16.0 directory, I am trying to run this command:
[root#ip-178-32-11-247 nifi-1.16.0]# bin/nifi.sh start
The Error message is:
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64
NiFi home: /root/nifi-1.16.0
Bootstrap Config File: /root/nifi-1.16.0/conf/bootstrap.conf
bin/nifi.sh: line 401: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/bin/java: No such file or directory
I thought that java is working but JAVA_HOME couldn't setup properly but I couldn't solve that. What should I do at that point to solve the problem and start nifi?
I will be appreciated very much if you can help, I coludn't start my term project because of this error :(
The correct path for JAVA_HOME should be /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.amzn2.0.2.x86_64/jre/bin/java"
But probably you don't need to export JAVA_HOME anyway. You should have a link in /usr/bin/. You can check this by doing the following:
[ssm-user#ip-172-31-85-243 bin]$ which java
/usr/bin/java
By default Apache Nifi is using the executable /usr/bin/java, so you don't need to export JAVA_HOME.
I'm trying to run the .net core sonarscanner tool on Jenkins (running on Linux) like:
dotnet sonarscanner begin ...
But it's giving the error
Could not find 'java' executable in JAVA_HOME or PATH.
I'm not sure why this is as I am explicitly setting the path at the top of my pipeline:
environment {
JAVA_HOME="${tool 'openjdk-11'}/jdk-11"
PATH="${tool 'openjdk-11'}/jdk-11/bin:$HOME/.dotnet/tools/:$PATH"
}
And from running the following commands I can see this looks correct:
sh "echo \"Java Home:\" $JAVA_HOME"
Produces:
Java Home: /var/lib/jenkins/tools/hudson.model.JDK/openjdk-11
And listing the directory:
sh "ls /var/lib/jenkins/tools/hudson.model.JDK/openjdk-11/jdk-11/bin"
produces:
+ ls /var/lib/jenkins/tools/hudson.model.JDK/openjdk-11/jdk-11/bin
jaotc
jar
jarsigner
java
javac
javadoc
javap
jcmd
jconsole
jdb
jdeprscan
jdeps
jhsdb
jimage
jinfo
jjs
jlink
jmap
jmod
jps
jrunscript
jshell
jstack
jstat
jstatd
keytool
pack200
rmic
rmid
rmiregistry
serialver
unpack200
Yet still, sonar scanner fails with the error:
Could not find 'java' executable in JAVA_HOME or PATH.
UPDATE:
Regarding Dimitry's comment - I am using the tools:
With this at the top of the pipeline:
tools{
jdk 'openjdk-11'
}
With regards to Marcinek's answer - good spot. I've realised that setting the JAVA_HOME at the top of the pipeline is not actually doing anything. Whatever I set it to, it remains as:
/var/lib/jenkins/tools/hudson.model.JDK/openjdk-11
The variable $JAVA_HOME should point to the main directory of java, where the bin folder can be found by appending bin
Your $JAVA_HOME variable is pointing to
Java Home: /var/lib/jenkins/tools/hudson.model.JDK/openjdk-11
To find the java executable you have to append jdk-11/bin
Thus the correct path to JAVA_HOME should be:
/var/lib/jenkins/tools/hudson.model.JDK/openjdk-11/jdk-11
And the PATH should point to:
/var/lib/jenkins/tools/hudson.model.JDK/openjdk-11/jdk-11/bin
You can use 'tools' section to use java in your pipeline.
pipeline {
agent any
tools {
jdk 'your-jdk-tool-name'
}
I am trying to install Maven on my Mac, but I can not get the JAVA_HOME variable right. The path that the maven website gives is,
usr/java/jdk1.7.0_51
however the java folder does not exist in /usr/ for me. I installed the JRE and JDK, nothing changed. How can I fix this?
Using brew - brew install maven - that's it.
Installing Maven (for me) usually involves these steps (apart from having a working java installed):
Download Maven from http://maven.apache.org/download.cgi
Unpack to /path/to/maven
Set the following in .bashrc
export M2_HOME=/path/to/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
Reload bash, and now "mvn --version" should be fine. Make sure to not have any reference to JAVA_HOME in your .bashrc (or .bash_aliases) if you havent already set it to somewhere you placed your jdk.
In my case, none of the exported variables saved after bash quit. Also, export M2=$M2_HOME/bin; export PATH=$M2:$PATH into bash didn't help, either. So, I had to write absolute paths into bash profile. Here are my steps:
1) open bash
2) next two steps are required to correctly create paths in your system. Type in (line by line)
JAVA_HOME=/usr/libexec/java_home
export M2_HOME=/path/to/your/apache-maven-3.x.x
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
3) than echo all four variables
echo $JAVA_HOME
echo $M2_HOME
echo $M2
echo $PATH
4) open second window of bash for your convenience.
5) choose root folder (type cd without anything and press enter)
cd
6) if you don’t have file called «.bash_profile» than just create it
touch .bash_profile
7) open edit your «.bash_profile»
nano .bash_profile
5) copy results of echo commands to your «.bash_profile». it should look something like.
JAVA_HOME=/usr/libexec/java_home
M2_HOME=/path/to/your/apache-maven-3.x.x
M2=/path/to/your/apache-maven-3.x.x/bin
PATH=/path/to/your/apache-maven-3.x.x/bin:/path/to/maven/bin:/$….bla-bla-bla…
6) after edit save by pressing ctrl+s and close by ctrl+x
For Macports : sudo port install maven3
Change maven3 to maven1 or maven2 for corresponding version number.
On Yosemite, I've not had JAVA_HOME defined and I have version '1.7.0_65'. I also have maven installed and use it nearly every day. Installation of maven is performed by the following steps:
curl http://download.nextag.com/apache/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz | tar pzxvf -
set the MAVEN_HOME environment variable to:
pwd/apache-maven-3.2.3
add MAVEN_HOME to your path.
Now you should be golden. Leave a comment if you aren't sorted.
Sorry this is late.
I installed JDK and Maven following instructions from each of those sites, then I had to edit my .profile file to get the PATH variables set.
$ sudo vim .profile
Then I added the following to my .profile (i for insert mode)
# JDK configuration
#
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
#
# Maven configuration
#
MAVEN_3_3_3=/opt/maven/apache-maven-3.3.3
export MAVEN_3_3_3
M2_HOME=$MAVEN_3_3_3
export M2_HOME
PATH=$PATH:$M2_HOME/bin
export PATH
Next you write and quit vim (:wq), quit and reopen terminal and type mvn --version to test your install.
Your output should look like this:
$ mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T06:57:37-05:00)
Maven home: /opt/maven/apache-maven-3.3.3
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
Note: you may need to adjust the paths to your jdk and maven installations.
So I tried to install openCV in Mac OS X and use it in my project, and I find some ways to do it, but when I install it, and use the command line trying to come up with the opencv2.4.9.jar file, but I can't find it anywhere.
This is what I did
$ cd opencv-2.4.9
$ mkdir build
$ cd build/
$ cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D WITH_CUDA=ON ..
$ make -j8
$ make install
Based on the tutorial, this should create a jar file in the opencv-2.4.9/build/bin, but I'd tried so many times, still can't find it.
Can someone tell me what is the problem? Thanks
may be your're lacking the JAVA_HOME environmental variable, which have to contain your JDK path. It happened in Ubuntu:
http://answers.opencv.org/question/34221/cant-find-opencv-249jar-file/?answer=34442#post-id-34442
Check return cmake command:
-- OpenCV modules:
-- To be built: core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: androidcamera dynamicuda java python viz
and
-- Java:
-- ant: NO
-- JNI: /usr/lib/jvm/java-7-openjdk-amd64/include /usr/lib/jvm/java-7-openjdk-amd64/include /usr/lib/jvm/java-7-openjdk-amd64/include
-- Java tests: NO
Check you JAVA_HOME :
$ ls $JAVA_HOME
ASSEMBLY_EXCEPTION bin include lib src.zip
THIRD_PARTY_README docs jre man
And Finally check if you have ant pacakge
$ sudo apt-get install ant
When I tried to run the R console in Eclipse, I got this error:
....Please make sure that R package 'rj' (1.1 or compatible) is installed...
So I tried to install it in the R console like this:
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")
and got this error:
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rj.gd', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/alex/R/x86_64-pc-linux-gnu-library/2.15/rj.gd/libs/rj.gd.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
and I found that when installing rJava using: install.packages("rJava") gets a similar error:
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/alex/R/x86_64-pc-linux-gnu-library/2.15/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
When I run sudo R CMD javareconf,I got this output:
Java interpreter : /usr/bin/java
Java version : 1.7.0
Java home path : /usr/lib/jvm/java-7-oracle/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
NOTE: Your JVM has a bogus java.library.path system property!
Trying a heuristic via sun.boot.library.path to find jvm library...
Java library path: $(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/lib/amd64/server
JNI linker flags : -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/lib/amd64/server -ljvm
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
Updating Java configuration in /etc/R
Done.
by the way,my configuration is:
Ubuntu 11.10 64bit
Eclipse 3.7
Oracle-1.7-jdk
R version 2.15.1
For Linux(Ubuntu) users: If you have oracle-java (7/8) installed. It'll be at this location /usr/lib/jvm and sudo access is required.
Create the file /etc/ld.so.conf.d/java.conf with the following entries:
/usr/lib/jvm/java-8-oracle/jre/lib/amd64
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
(Replace java-8-oracle with java-7-oracle depending on your java version)
Then:
sudo ldconfig
Restart RStudio and then install the rJava package.
OR
Also an alternative method is to export LD_LIBRARY_PATH with the value of Java library path obtained from the command R CMD javareconf -e and run install.packages
I got similar issue and was able to resolve it by running
R CMD javareconf -e
Output of the R CMD javareconf -e
Java interpreter : /export/apps/jdk/JDK-1_6_0_27/jre/bin/java
Java version : 1.6.0_27
Java home path : /export/apps/jdk/JDK-1_6_0_27
Java compiler : /export/apps/jdk/JDK-1_6_0_27/bin/javac
Java headers gen.: /export/apps/jdk/JDK-1_6_0_27/bin/javah
Java archive tool: /export/apps/jdk/JDK-1_6_0_27/bin/jar
Java library path: /export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64/server:/export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64:/export/apps/jdk/JDK-1_6_0_27/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
JNI linker flags : -L/export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64/server -L/export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64 -L/export/apps/jdk/JDK-1_6_0_27/jre/../lib/amd64 -L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib -ljvm
JNI cpp flags : -I/export/apps/jdk/JDK-1_6_0_27/include -I/export/apps/jdk/JDK-1_6_0_27/include/linux
The following Java variables have been exported:
JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
Running: /bin/bash
After setting LD_LIBRARY_PATH to the same value as JAVA_LD_LIBRARY_PATH as shown in the output above. I was able to install rj.
export LD_LIBRARY_PATH=/export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64/server:/export/apps/jdk/JDK-1_6_0_27/jre/lib/amd64:/export/apps/jdk/JDK-1_6_0_27/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Run R and then install rj by
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")
I found the solution:
export LD_LIBRARY_PATH=/usr/lib/jvm/java-7-oracle/lib/amd64:/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server
then
sudo R CMD javareconf
Note: The path (java-7-oracle) needs to be updated based on your Java installation.
I did the following and it worked for me:
export LD_LIBRARY_PATH=$JAVA_LD_LIBRARY_PATH
sudo R CMD javareconf
I had to restart R then as well.
Years later, I ended up on this question after searching for an error reported by R after I had unsuccessfully installed a package on that required shifting to Oracle's Java.
All I had to do to fix it was:
$ sudo R CMD javareconf
or just set the library in R?
I just ran this command in R:
Sys.setenv(JAVA_HOME='/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server')
(replace "/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server" with your Java library path which can be found running "sudo R CMD javareconf")
Might not be the most elegant solution - but it worked for me!
I did not had the jdk installed which I could fix with
sudo apt-get install jdk-*
After that i could run the sudo R CMD javareconf which always drew an error message before. Everything was set correctly and no manual tweeks where required, and after that package installation ran smootly in R (restart required).
When facing missing limjvm.so errors make sure that the correct ldpaths is picked up from the standard configuration in /etc/R versus the one in /usr/lib/R/etc.
This fixes the LD_LIBRARY_PATH problem for me (Linux, Debian 7.1.0, tc-shell, R version 3.0.2):
Add this line to .cshrc:
setenv LD_LIBRARY_PATH $JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server
Adding this command to ~/.login was not enough; the environment variable LD_LIBRARY_PATH was still not known in new xterms: echo $LD_LIBRARY_PATH : LD_LIBRARY_PATH: Undefined variable. (Why??)
Curiously, when starting R as superuser, there was no problem with finding libjvm.so .
I fixed this by just running R with sudo, and then running install.packages('rJava`).
None of the above worked for me, the only solution that installed rJava on Linux Ubuntu without any problems was to pass RScript command after installation of the base R:
$ sudo Rscript -e 'install.packages("rJava", repos = "http://cran.r-project.org/")'