Loading libraries on Raspbian - java

I'm running a Java application on the Raspberry Pi 3B, my OS is Raspbian.
The application (which has been written on a x64 Windows system) relies on the Dropbox Core sdk-3.0.6 to download some data from a Dropbox server. The Dropbox Core SDK needs another library called the Jackson Core 2.7.4 SDK.
I've imported both jar.files to the directory /home/lib/. I'm running the application from the following .bat file:
> java -cp /home/lib/jackson-core-2.7.4.jar;/home/lib/dropbox-core-sdk-3.0.6.jar -jar /home/ComRoll.jar
I keep on getting errors because of these libraries. Most common error is concering the jackson library: "Cannot execute binary file". Something that's maybe worth mentioning is that the error message differs depending on the order of the libraries in the .bat file. When I construct the file in the following way there are other messages:
> java -cp /home/lib/dropbox-core-sdk-3.0.6.jar;/home/lib/jackson-core-2.7.4.jar -jar /home/ComRoll.jar
I'm new to Linux-based systems and hoping I'm missing something really obvious here because I'm starting to fear that the entire Dropbox SDK wouldn't be eligible for Raspberry Pi.

The comments of mkasberg pointed me in the right direction.
I built a fat jar with the libraries I used during development on the Windows system.
Eventually there were some problems with that approach too: some of the libraries were signed. I excluded those libraries from the project and now the fat jar seems to be running smooth on the raspberry.

Related

How to get dll equivalent file in macos from the installed application

I am new to java working on voip project linphone-desktop(cross-platform) project. I can generate the build files from the code available on the github. I can install linphone-Desktop application from the dmg file in my system but not sure from where I can find the dylib file to use it in my project to customize the linphone-desktop application as per my requirement.
Firstly, I have tried to use the dll file on my macos but later I have found that dll file on macos can be used through the WINE only but I am using MacOS 10.15(Catelina) on which wine is not supported.
Listing few links which I have already visited.
https://www.chilkatsoft.com/java-loadlibrary-windows.asp
dll can be loaded on MAC os
Loading DLL in java in UNIX system
Any help would be highly appreciated.

Running Windows-Compatible .jar files on Linux?

Our CE project includes a .jar file which is written for Windows only for some reason. Unfortunately, I do all my coding related projects on Ubuntu and I'm really not willing to install VS on windows and start over on a new environment and lose a lot of efficiency.
The jar file requires some other files to work but the directory formats differ in Linux so I'm getting errors of it not finding the files when I try to open it from Linux.
I've already asked for the source code or a more compatible version but the TA's aren't really cooperative in my case.
Is there any way I could circumvent this problem and fix the incompatible directory formats issue(For example by running through wine)?
Edit: I tried decompiling the jar, but it wasn't fully successful and some of the files came out corrupted.
Because the original maintainers didn't think that this JAR would be run on other OSes, you're stuck placating their arbitrary requirement. You're going to want to use a VM (Wine isn't an emulator and you're going to run into significant pain using it and Java to run a JAR) to set this up and execute their JAR.
Once you get a hold of the source, you can build a new JAR which asks the OS which file separator to use instead of allowing the code to assume Windows. Or use NIO.

How to call an embedded jre from command line in order to run java applications

Is it possible to bundle a JRE within an exported stand alone Java app? We have a very specific requirement to run a standalone AnyLogic Java app on a machine that does not have the latest Java version installed and due to company IT policies we will not be able to do so
Through some research I have found some sites to claim that they have already been doing it for Windows and Mac.
Using a bundled JRE on OSX
https://wiki.openjdk.java.net/display/MacOSXPort/How+to+embed+a+.jre+bundle+in+your+Mac+app
http://www.intransitione.com/blog/take-java-to-app-store/
My issue is that most of these posts refer to bundling an app for Mac OS x and requires that the jar files be created in an IDE like Eclipse. But since I use AnyLogic the jar files gets exported without myself being able to intervene. What I need is to change the command line code that runs the jar files and currently looks like this:
java -Xdock:name="AnyLogic Model" -Dnativewindow.awt.nohidpi=true -cp com.anylogic.engine.jar:com.anylogic.engine.nl.jar:lib/database/querydsl/querydsl-sql-codegen-3.6.3.jar -Xmx256m model6.Simulation $*
(Note: Code reduced for readability)
into something that I assume will pass the jre or JVM to be used as an argument to the java call. Or maybe set the directory to be used for java or something... as calling the java command on a machine without java installed renders nothing.
I have a very simple app, as well as a jdk plugin that I got from the moneydance app, which is a java app that runs on OSx with its own embedded jre, available here
https://www.dropbox.com/sh/1bedimsb0lj403t/AADYR7iFoBD4YiqS_RGZ2xAVa?dl=0
Thanks
A colleague of mine who is not on Stack Exchange gave me the answer so here goes, actually quite easy:
In order to meet my specific circumstances one just needs to include a jre inside the root of the folder that you supply to a client and then reference the the java executable in the execution file. The solution for Windows and Mac are slightly different so here goes:
On Mac
You can find the jre in the following folder. It is a hidden folder so if you Mac is not set to show hidded folders go to finder use command-shift-g and go to
/Library/Java/JavaVirtualMachines/
there should be a jdk folder and then navigate to
jdk1.8.0_45.jdk/Contents/Home/jre
On Windows
The location of the jre is in
c:\Program Files\Java\
you can see the location in the .bat file that AnyLogic creates automatically in line of code that looks like this:
#SET PATH_XJAL="%DISK_XJAL%\Program Files\Java\jre6\bin\java.exe"
Once you have the jre copy this folder to the same location as the stand alone java app. Then the only thing that remains is to change the referenced location in both mac command line executable and the windows.bat file
On Mac
Change from
java -Xdock:name="AnyLogic Model"
to
./jre/bin/java -Xdock:name="AnyLogic Model"
On Windows
Change from
#SET PATH_XJAL="%DISK_XJAL%\Program Files\Java\jre6\bin\java.exe"
to
#SET PATH_XJAL= \jre6\bin\java.exe"
Running the java app on both Mac and Windows will now be independent from the Java version on the machine or whether it is installed or not
another alternative is to compile your compiled application into an executable using Exe4J. It is not free but another advantage is that you send your client only a single exe-file, not a bunch of files. (Disclaimer: not tried with the internal AL7-dbase yet but it works fine when accessing external data).

java doesn't recognize so libraries

I'm trying to develop a BitTorrent client using the frostwire jlibtorrent librari, but when I run the program alwais obtain the error on the image.
How I can compile using the linux version of the library.
Hi do you run on linux or windows or Mac? The exception indicates that a binary lib can be loaded or found. (the .so file as you indicate).
There is a case the native lib included in the jar - is not compatible or has missing dependencies (links) on your host OS. See here.
The .so library has to be loaded first before it can be used. Use System.load() to do so. Here is an example:
https://www.chilkatsoft.com/java-loadLibrary-Linux.asp

Exporting a program in Eclipse that works for people not familiar with Java programming

I made a little minesweeper game and I want to send it to a friend so he can test it out. The problem(probably) is that he isn't able to run it because he doesn't have Java for programmers(JDK) installed on his computer. How is it possible to export a program that will work on other computers without having to download any other files**(other than JRE)**?
EDIT: I did read about converting the JAR to EXE but I couldn't find anything that would do it.
EDIT2: Download here the JAR file(it's only supposed to open a blank window). I tested it on two computers with JDK installed and it worked, whilst on two others without JDK(one with the newest JRE) it couldn't start. This is the error:
.
There is no way to "not have to download any other files" - your friend must minimally have some Java Runtime Environment (or just "Java") installed in order to run Java programs.
If your friend has Java installed, you can package your application as a fat JAR so that he only needs your JAR to run your application (depending on the application - but I think yours should be fine).
There are tools available, google "java windows executable" and you will find e.g.
Convert Java to EXE
http://jsmooth.sourceforge.net/
Or already on SO
How can I create a Windows .exe (standalone executable) using Java/Eclipse?
Java Web Start is ideal for this, as it can enable the user to install required components on supported platforms. There's a simple example here.
Not possible, a JRE (Java Runtime Environment) is the least that must be present.
If that is you can just export your program as jar specifying the main class in its manifest. Your friend should if a JRE is installed be able to run the jar file directly.
You could send your friend the compiled binary of your game. In that scenario, your friend will only need to have the Java Runtime Environment installed in order to play your game.
Make executable JAR from it, your friend will still need JRE.

Categories