How to implement Asprise OCR Library - java

Could someone please tell me how to implement the Asprise OCR library into my java program.
I'm using Eclipse and I know how to import the .jar but as soon as I want to run my program it gives me errors about a .dll file that's missing.

I fixed it, I just had to copy the .dll that came with the .jar to System32.
If you don't want to add them to System 32 just add them to your workspace and use
'System.load("dll_name_without_.dll_at_the_end");'

Just FYI, Asprise OCR library for Java automatically handles the native library files since version 5.0.
Java offers two methods to load libraries and a good explanation is here
Difference between System.load() and System.loadLibrary in Java

Related

Is there a possibility to run a jar file within an android application with another jdk?

Im new to app development and was wondering if it would be possible to include another jdk. For example java 17 and run a jar that needs to be run in this exact version? I think termux has an api that you may use for these purposes but is there another possibility? These jars are only console based and without any gui.
I first tried to use the jar as a android library inside the app, which did not work since it was compiled in java version 17. I tried decompiling the jar and recompiling it with the version I was using. The problem is that all the libraries used are on other versions than I need them to be and so I could not recompile it. I also thought about writing the application in c# but I am not used to it at all, which would throw many new problems that I would be willing to take if it would be a possibility to work out my project.
Q: Is loading the code into your Android application an option?
A: No.
Android loads code from ".dex" files not ".class" files.
The ".class" files would need to be translated using dx.
The Android dx command doesn't understand Java 17 ".class" file format.
Also the code in the JAR is likely to depend on classes in the Java SE class library that the Android doesn't provide.
Q: What about running it in a separate Android VM?
A: No.
An Android VM requires ".dex" files; see above.
Also, the Java SE class library issue; see above.
Q: What about launching an OpenJDK or Oracle Java 17 JVM on the Android device to run the JAR?
A: In theory Yes, but in practice No. As far as I am aware, there is no port of OpenJDK Java SE to the Android OS platform.
Q: What about using Termux?
A: OK ... that might work. See Is it possible to install the JDK on an android device?.
I have no experience with this, and don't know what problems you may run into doing this. But I suspect that you wouldn't be able to distribute something that relies on Termux via the Google Playstore.
Another option is to download the source code1 for the application and try to build it in your Android dev environment
If the code uses Java classes / packages / libraries that are not available for Android, recode the relevant parts of the application to use Android equivalents instead.
Ditto if the code uses Java language features that are not yet supported in Android Java.
It probably won't be easy. It may turn out to be impractical.
1 - You said in a comment that the code your are trying to use is "open source". So the "download source and build it" option is available to you. I'm puzzled why you tried to decompile and recompile it instead ...

APK and Java Standard Library and SDK Platform

When I analyze an APK, I see classes.dex and it supposed to contain my Java code and it does, why it also contains Java standard Library (java.io.) and the SDK platform (android.app.) which I used to compile the project.
Can anybody explain why are they included?
Basically, when we are writing any program we need to import the classes which are needed. So, likewise to run the program, it needs those code. The java.io or android.support are nothing but some codes written.

Android Studio - How does a library project used in an app follow with the app-release.apk

I'm using a library (https://github.com/PhilJay/MPAndroidChart) for plotting data in an android app. When app-release.apk is created by the program it is ready to be installed on the tablet I use for testing.
What is puzzling to me is how the parts of the library, which i use, follow with the release. In other scenarios, for example in Visual Studio and c# - program being installed on Window machine, libraries require dll files to be installed and registered on each targeted machine. In my scenario the library is written specifically for Android, but if I somehow managed to include a c++ or a c# library in my Android app using tools like libstdc++ or MONO, would it work the same way when it comes down to app-realease.apk?
Are all classes in a library included in the app-release.apk or just the parts that I use?
Thanks in advance and please let me know if the question is unclear before downvoting it!
Normally, when you build your APK, all the libs you have imported (jars) are included and transformed to dex files, as the rest of your code. So, yes all the classes are included, even if you don't use them.
You can use Proguard to remove them from the APK. Look at this post :
Use Proguard for stripping unused Support lib classes

I want to know if is possible to build the OpenCV Java library for a embebed system with a architecture armv7?

well i'm trying to develop an application for a beagleBone black (armv7) with the jdk installed. If it's possible, can say me how to do it? I use the cross-compiler recommended in the page of openCV for embebed system but it only generate me a c++ library, and I need the .jar whit the .so file.
http://docs.opencv.org/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.html#arm-linux-cross-compile
I have developed application in OpenCV for BeagleboneBlack. But this application is in C++. All you need are the arm compatible .so files. Just download the binary package of JavaCV. Extract it, you will find the binaries for Android. These are compiled for arm devices. Use these libraries for Beaglebone.
Hope it will solve your problem.

How to create native binaries for your Java app? [duplicate]

This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 3 years ago.
I'm wondering how to package a Java application into a native binary for Windows, Linux and Mac OS X.
I know Minecraft does this, but I can't figure out how. This is what'd I'd like to do:
From NetBeans (preferably) or Eclipse, build the three binaries automatically.
Include native libraries for OpenGL et. all.
Obfuscate my code if possible.
If there's some way to mimic the Minecraft auto-updater feature, that'd be totally awesome.
So, are there any tools available to do this for you, or do I need to write a large bulk of XML to accomplish this?
To make a native binary for Windows, you would use a tool like Launch4J. On OSX you could use JarBundler. Minecraft simply distributes the jar file for Linux. I'm not aware of a native binary packager for Linux.
You could also compile your Java code via GCJ but that's probably not what you want, as there are limitations and compatibility concerns there. The native bundlers like Launch4j and JarBundler simply wrap your jar file and use a real JRE to execute it.
As for integrating with NetBeans or Eclipse, you'll probably have to write your own ant build file, especially since the solution varies from one platform to the next.
If you are using Java 9, you can also use Java 9 Modularization & jlink to ship a zero-dependency native app.
There is also maven-jlink-plugin that could help here.
Take a look at GCJBuilder plugin for eclipse. Not sure if it supports cross compilation as the command GCJ compiler does.
If the app. has a GUI and can be distributed from a web site, look into Java Web Start. JWS is supplied by Oracle, and provides auto-update amongst many other features.
Note that JWS uses Jar files, so no conversion is necessary.
I've used JSMooth for this in the past: http://jsmooth.sourceforge.net/
As mentioned before, this wrapper just looks for a real JRE to run it - it does not come with a bundled JRE.

Categories

Resources