Install ANT (and JAVA) on server - java

I am trying to install ANT (to build/compile Android apps) on a local Linux (Ubuntu) installation so that I can install it on a live server (work out the kinks first).
The following is a set of commands I have run to get to where I am:
wget http://archive.apache.org/dist/ant/ant-current-src.zip /dest/folder
unzip ant-current-src.zip
wget http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-x64.bin /dest/folder
./jdk-6u25-linux-x64.bin
(backup PATH :P )
export JAVA_HOME=jdk1.6.0_25 export
PATH=$PATH:jdk1.6.0_25/bin
wget http://voxel.dl.sourceforge.net/project/junit/junit/4.10/junit-4.10.jar
cp junit-4.10.jar junit.jar
rm junit-4.10.jar
export CLASSPATH=$CLASSPATH:$JUNIT_HOME
With the following screenshot showing the output of the terminal:
At this point I'm stumped...
RESOURCES:
http://ant.apache.org/manual/index.html -> Installing Apache Ant -> Building Ant

You do not need to build ant to use and you can just install Java and Ant from the ubuntu packages.
sudo apt-get install ant
should install Java and ant for you.

Related

Run gauge tests inside a docker container

I'm trying to Dockerize a Gauge test automation project so I can run specs inside a Docker container. The project is written in Java and Spring Boot.
I saw this tutorial in Gauge documentation.
This is the DockerFile in the tutorial:
FROM ubuntu
# Install Java.
RUN apt-get update && apt-get install -q -y \
openjdk-8-jdk \
apt-transport-https \
gnupg2 \
ca-certificates
# Install gauge
RUN apt-key adv --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys 023EDB0B && \
echo deb https://dl.bintray.com/gauge/gauge-deb stable main | tee -a /etc/apt/sources.list
RUN apt-get update && apt-get install gauge
# Install gauge plugins
RUN gauge install java && \
gauge install screenshot
ENV PATH=$HOME/.gauge:$PATH
As you see, there's no "ADD"/"COPY" there in the DokcerFile.
Is it just suggesting an alternative to install Gauge and the other packages on the host?
Any ideas on how to run the specs inside a Docker container?
Here is what I did to get the test running in the docker container.
I have a specs folder beside src in my project structure meaning the gauge tests will run using the JAR file but they're not part of the JAR file themselves.
--MyProject
----specs
----src
...
I used maven to run the test inside the container. That's why I preferred to build the project inside the container so I get the JAR file ready with the same version of maven I run the test with.
Here is the DockerFile. I developed a bash script to run the test. You may run the script with CMD or ENTRYPOINT:
FROM maven:3.6.1-jdk-8
# add any project resources needed
ADD env /home/e2e/env
ADD specs /home/e2e/specs
ADD src /home/e2e/src
ADD src/main/scripts/entrypoint.sh /home/e2e/
ADD pom.xml /home/e2e/
RUN ["chmod", "+x", "./home/e2e/entrypoint.sh"]
# Install Gauge, web browser and webdriver in your preferred way...
ENV PATH=$HOME/.gauge:$PATH
# I'm keeping the cntainer running. But it's all up to you.
CMD /home/e2e/entrypoint.sh && tail -f /dev/null
And then here is the simple entrypoint.sh script:
#!/bin/bash
cd /home/e2e/
mvn clean package
gauge --version
google-chrome --version
mvn -version
mvn gauge:execute -DspecsDir=specs/myTest.spec
Of course, you could just use a ready JAR instead of building it inside the container. Or you could build the JAR while creating the docker image.

Adding Archive to Libre Office using Docker

In one folder I have two files: Dockerfile and postgresql-42.2.4.jar
Dockerfile:
from ubuntu:16.04
RUN apt-get update && apt-get install -y \
libreoffice-base
COPY postgresql-42.2.4.jar postgresql-42.2.4.jar
CMD ["usr/bin/libreoffice"]
postgresql-42.2.4.jar:
I downloaded PostgreSQL JDBC archive from PostgreSQL official site
To run docker I used:
docker build -t gui-app .
then:
docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" gui-app
Libre Office run correctly, but when I want to add Class Path (link to Libre help site) I can't find .jar file which I copied in Dockerfile.
I didn't manually install JRE, but I think JRE is build in ubuntu.
Why I can't find JDBC archive file?
There is no JRE installed by default in the docker image ubuntu:16.04. You can inspect the list of installed packages by running:
docker run -it ubuntu:16.04 apt list
You can install the default JRE in your Dockerfile by adding the default-jre package:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
libreoffice-base default-jre
COPY postgresql-42.2.4.jar postgresql-42.2.4.jar
CMD ["usr/bin/libreoffice"]

apache ant Could not find or load main class org.apache.tools.ant.launch.Launcher

I'm trying to compile a tool which uses apache ant on linux
https://github.com/lindenb/jvarkit
When I tried to compile the tool , I get n error.
$ make vcffilterjs
this is what I get when I'm running the command
echo "Compiling htsjdk with ${JAVA_HOME} = /usr/lib/jvm/java/jre/"
Compiling htsjdk with /usr/lib/jvm/java/jre/ = /usr/lib/jvm/java/jre/
echo "Compiling htsjdk library for java. Requires apache ANT. If it fails here, it's a not a problem with jvarkit."
Compiling htsjdk library for java. Requires apache ANT. If it fails here, it's a not a problem with jvarkit.
echo "And ${JAVA_HOME}/bin/javac should be >=1.7"
And /usr/lib/jvm/java/jre//bin/javac should be >=1.7
(cd /home/jannahS/jvarkit/htsjdk-1.139 && ant )
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
make: *** [/home/jannahS/jvarkit/htsjdk-1.139/dist/htsjdk-1.139.jar] Error 1
I have installed apache ant and tried to set ANT_HOME following google instruction
export ANT_HOME=apache-ant-1.9.6
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PAT
I also have set JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/jre-1.7.0
export PATH=$JAVA_HOME/jre/bin:$PATH
When I run
ant --execdebug
exec "/usr/lib/jvm/java/jre//bin/java" -Xmx256M -classpath "apache-ant- 1.9.6/lib/ant-launcher.jar" -Dant.home="apache-ant-1.9.6" -Dant.library.dir="apache-ant-1.9.6/lib" org.apache.tools.ant.launch.Launcher -cp ""
Buildfile: build.xml does not exist!
Build failed
I don't know what else to do to make things to work. I can't compile the tool that I want to use without apache ant
Use full path in ANT_HOME, eg:
export ANT_HOME=/usr/lib/apache-ant-1.9.6
It dependes where it is exactly located
Could not find or load main class org.apache.tools.ant.launch.Launcher
In mac this is due to some environment issue if you install the ant using brew command,
copy the lib folder from the ant and paste it into the bin folder
now run the command issue is resolved:-)
issue reason
ant is trying to get the bin/lib/ant-launcher.jar file from the invalid path
In Mac, after running brew install ant, I had to run brew link ant to fully link ant to system environment.
Running brew link --verbose --overwrite ant I get:
Linking /usr/local/Cellar/ant/1.10.5...
ln -s ../Cellar/ant/1.10.5/bin/ant ant
ln -s ../Cellar/ant/1.10.5/bin/antRun antRun
ln -s ../Cellar/ant/1.10.5/bin/antRun.pl antRun.pl
ln -s ../Cellar/ant/1.10.5/bin/complete-ant-cmd.pl complete-ant-cmd.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.pl runant.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.py runant.py
6 symlinks created
And when running "ant" with no params from command-line:
Buildfile: build.xml does not exist!
Build failed
Which is what I expect if testing outside the context of an existing ant project.
Run "which ant" >> to know if the ant_home set. If not please run below with your corresponding paths to set ant_home
export ANT_HOME =/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant
export PATH=/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant:${PATH}
Try ant build. It should work without any error.
"I agreed with full path issue for the above issue, getting the same exception while folder has access problem"
I have faced the same exception in Macbook. Checked all the configurations JAVA_HOME, ANT_HOME and org.apache.tools.ant.launch.Launcher file in Ant related jars. Finally, found the issue, due to an access problem of the apache-ant folder. I have no admin access, so I moved my setup to the desktop.
$ make vcffilterjs : Compiles OK, with any of these "Linux OS´s" :
Debian 8 Jessie, CentOS 7, Fedora 23, Ubuntu 15.10, PCLinuxOS 2015.
No "ANT_HOME" or "JAVA_HOME" settings required, by using the default installed 'ant' and openjdk.
? Which "Linux OS" are you using ?
antjvarkit

0 NATIVE_LIBRARY_NAME cannot be resolved or is not a field with Linux + Eclipse + Java

I get an error on Core.NATIVE_LIBRARY_NAME like so:
Stacktrace:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
NATIVE_LIBRARY_NAME cannot be resolved or is not a field
at MyVideoCap.main(MyVideoCap.java:7)
I had settled the NativLibrary path at the following location.
/home/.../OpenCV/opencv-2.4.5/build/lib
I had followed the instruction on https://www.openshift.com/blogs/day-12-opencv-face-detection-for-java-developers but it doesn't creates any opencv2.4.9.jar file I am working on ubuntu 12 and eclipse with opencv api suppoert.
so help me if you can to generating and building the jar file in the build directory in ubuntu. thanks in advance...
Here I found the full Installing progress of the OpenCV...
# install basic development environment
sudo apt-get install build-essential cmake pkg-config
# install opencv dependencies. ubuntu 13.04 ships with opencv which is close enough to 2.4.6 to pull in most of the needed dependencies.
sudo apt-get build-dep libopencv-dev
# additional dependencies for java support
sudo apt-get install default-jdk ant
# compile opencv
tar xzvf opencv-2.4.6.1.tar.gz
cd opencv-2.4.6.1
mkdir build; cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON ..
make
sudo make install
And in last don't forget to set Native library path to the
/home/.../opencv-2.4.6.1/build/lib
Thats it...

Trunk doesn't compile because libprotoc is old when working with Hadoop under Eclipse

I am following "working with Hadoop under Eclipse" and trying to run
$ mvn install -DskipTests
After a while, I received an error:
[ERROR] Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:3.0.0-SNAPSHOT:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: protoc version is 'libprotoc 2.4.1', expected version is '2.5.0' -> [Help 1]
It is the same as what is reported in this page.
Does anyone know how to solve it? How should I do to upgrade libprotoc?
Protocol Buffers is used as an RPC protocol between different daemons. Some of the Linux releases don't have the required version. So, Protocol Buffers code has to be downloaded from here, built and installed. These are the instructions from the README.txt in the downloaded bundle.
To build and install the C++ Protocol Buffer runtime and the Protocol Buffer compiler (protoc) execute the following:
$ ./configure
$ make
$ make check
$ make install
If "make check" fails, you can still install, but it is likely that some features of this library will not work correctly on your system. Proceed at your own risk. "make install" may require superuser privileges.
Execute this bash function, which will download protobuffer 2.5.0 and install with sudo permission. (Tested in ubuntu 13.04)
configureProtoc(){
sudo apt-get install -y gcc g++ make maven cmake zlib zlib1g-dev libcurl4-openssl-dev
curl -# -O https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
gunzip protobuf-2.5.0.tar.gz
tar -xvf protobuf-2.5.0.tar
cd protobuf-2.5.0
./configure --prefix=/usr
make
sudo make install
}
Dont forget to link shared libraries after installing protoc :
ldconfig

Categories

Resources