How to build jar Library for openconnect client? (no configure file) - java

I want to build a jar-library for the openconnect client. But I couldn't find the configure-file there is only a configure.ac file that seems to include the code for the configure file. The content of the readme-file couldn't help me:
Description:
This directory contains a JNI interface layer for libopenconnect, and a
demo program to show how it can be used.
Build instructions:
From the top level, run:
./configure --with-java
make
cd java
ant
sudo java -Djava.library.path=../.libs -jar dist/example.jar <server_ip>
If ocproxy[1] is installed somewhere in your $PATH, this can be run as a
non-root user and it should be pingable from across the VPN.
Test/demo code is in src/com/example/
OpenConnect wrapper library is in src/org/infradead/libopenconnect/
[1] http://repo.or.cz/w/ocproxy.git
ant worked but ./configure didn't work.
Any suggestions?

Related

How do I use a library on a exported runnable jar?

I've got a java script that uses OpenCV 4.6.0 to modify some pics. I use Eclipse to edit the java project. I downloaded the OpenCV library (a opencv_460.jar file) which is used inside Eclipse. When I run the code, it works just fine. So I export the java project as a runnable jar.
The thing is that I want to use the jar on a different machine (ubuntu 18.04). When I run java -jar TheExportedJar.jar, I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java460 in java.library.path: /usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
I installed OpenCV 4.6.0 on the machine using CMake
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.6.0.zip
unzip opencv.zip
mkdir opencv-4.6.0/build
cd opencv-4.6.0/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PKGCONFIG=ON ..
make -j$(nproc)
sudo make install
The version is ok, everything looks fine, except it doesn't actually get installed. Things that should exist, like alternative path /usr/local/lib/pkgconfig/opencv4.pc, don't actually exist
How does java work? Why can Eclipse use a jar as a library, but I can't once the project is packed? Is there a way to skip the installation process (as every type of install I've tried was just a waste of time) and import a jar from a specified path as a library inside the java code?
What other solutions could there be?

Running an android binary on Ubuntu (libc.so: invalid ELF header)

I am trying to run a java application on spring boot running on ubuntu. My application has a dependency on a jar file that loads two binaries:
"libc++_shared.so" and "libsigx.so"
I extracted the jar file and so files from an aar file that is created as a dependency for android, but I would really like to use this on my server. I was able to write the java code I need without an issue after I added the jar file as dependency to my spring boot application.
However, when these binaries are loaded(e.g System.loadLibrary("c++_shared")) in Java, I got an exception saying that libc.so is not found. Apparently, I needed to install some other binaries, so I installed the necessary binaries to my docker container by using
sudo apt-get install build-essential
Now I have all the binaries needed(libc.so, libm.so etc), but now when I run my jar file I get invalid ELF header exception:
Caused by: java.lang.UnsatisfiedLinkError: /usr/java/packages/lib/libc++_shared.so: /lib/x86_64-linux-gnu/libc.so: invalid ELF header
When I run the readelf -h command on so files:
The c++ so file has OS/ABI: UNIX - System V header, while libc.so has OS/ABI: UNIX - GNU. Looks like binaries are not compatible and I am trying to find to solve this.
Couple of questions that come to mind are:
Is it possible to get these binaries to run in a compatible way with some commands? Maybe convert binary for system v to gnu somehow?
Is it possible to find "libc++_shared.so" and "libsigx.so" created for OS/ABI: UNIX - GNU
I am open to any workaround to get these libraries running together. Thanks

package org.junit does not exist

I am using Jenkins, and using a Github repo as Source Code.
In the Build section, I am executing this as a Windows Batch command:
set path=%path%;C:\Program Files\Java\jdk1.8.0_144\bin
cd \Users\harr\JenkinsServer\JenkinsTest\src
javac SimpleTest.java //Error is after this executes
java SimpleTest
I know it has something to do with classpath, but I am unsure how to solve this problem in jenkins.
Let me know if more information would be helpful.
Suppose you deploy the jekins server on linux platform, so you have to install the jdk, tomcat and so on, set the env path as well. Then you don't have to execute set path before every build.
you can create a script and copy the command into it, then when jenkins performs the build task, it can execute the script. Refer to the jenkins tutorial to learn about it.

Android building: JarJar can't find or load main class

I'm trying to build AOSP from source (With a few modifications) but my build stops with
[ 0% 1/35196] JarJar: out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar
FAILED: /bin/bash -c "java -jar out/host/linux-x86/framework/jarjar.jar process external/conscrypt/jarjar-rules.txt out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-full-debug.jar out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes-jarjar.jar"
Error: Could not find or load main class com.tonicsystems.jarjar.Main
ninja: build stopped: subcommand failed.
make: *** [build/core/ninja.mk:149: ninja_wrapper] Error 1
and i can't get to fix it. My source is hosted here and the path of external/jarjar is the stock one on googlesource.
Can anyone help?
I had the same problem until I realized that it's due to the wrong path where com.tonicsystems.jarjar.Main is located. At ~/android/system, JarJar's com.tonicsystems.jarjar class is located in:
external/jarjar/src/main/com/tonicsystems
When it should be
external/jarjar/src/main/java/com/tonicsystems
Like it's source (from GitHub)
src/main/java/com/tonicsystems/jarjar
P.S: I had to create the external/jarjar/src/main/java directory and then move the source.
I've run into this with an AOSP fork (I think Qualcomm's tree) before - that was caused by the Makefile fragments that generate the file lists for the jar files not dealing properly with localized versions of the "sort" utility (causing removal of important class files in addition to the duplicates that were supposed to be removed).
I don't remember all the details or the proper fix, but the workaround that got me going initially was simply disabling localization while building.
rm -rf out
export LANG=C
export LC_ALL=C
export LC_COLLATE=C
. build/envsetup.sh
lunch whatever
make droidcore -j8
What fixed this for me was something completely unrelated to jarjar itself.
I was building AOSP 7.1.1 on Ubuntu 20.04. The default python command on Ubuntu 20.04 points to python3 [1], but AOSP 7.1.1 builds using python (which is really python 2.7.5).
I updated my system with sudo apt install python which linked the python command to python2 correctly instead of python3. After this, I built successfully.
AOSP is shipped with python under the prebuilts/python directory and I'm still confused as to why the build system doesn't point to that python version.
Edit
I had more trouble with adjusting my system to use the correct version of python, ultimately I had to add python and python3 as alternatives.
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
$ sudo update-alternatives --config python
Select python2

How to Run a Java Project on Linux Without Using IDE

I am new to Java.
Basically, I developed a java projects which contains multiple Java packages inside Eclipse. The project runs OK on my desktop with a redhat Linux installed. However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. Therefore, it is impossible to run Eclipse on that server.
Is it possible to do that? If so, how can I move the entire project to that server including the input and output folders?
Thanks
In Eclipse use the "Export Runnable Jar" option. Highlight your project then click file->Export, choose Java, choose Runnable Jar file. Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class.
You will need to install the JRE on the machine you want to run it on. This can be done with the following command:
yum install java-1.6.0-openjdk*
Once you have java then it is simply a matter of executing your application. I would recommend using eclipse to compile your project to a jar and use the following command to execute it:
java -jar *JarFileName*.jar
Running Java is nothing to do with Eclipse . You can run your java program in linux machine by opening terminal .
Step1;- Set your JAVA_HOME in your bash profile .
Step2:- open terminal , go to the folder or package where your main program is present.
Step 3:- compile it using javac -cp lib.jar Filename.java
Step 4:- After compilation class file will be available , run it using java filename.java
Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available
http://eclipse.org/downloads/?osType=linux

Categories

Resources