Mupdf documentation shows me how to use the library as an application and deploy it. However, I want to suck it into an existing java project and build my application on top of it. Can this be done? If so, how do I bring just the pieces needed, into my project?
Take a look at jMuPdf. I never used it, but it seems to be active.
Otherwise you will need to create Java Native Bindings (JNA or JNI).
Related
I am trying to write a standalone Java application in IntelliJ using edu.stanford.nlp.trees.GrammaticalStructure. Therefore, I have imported the module:
import edu.stanford.nlp.trees.GrammaticalStructure;
Currently, Intellij doesn't recognize this and many others of the imported external libraries (cannot resolve the symbols) and is also not able to automatically download/import them.
Is there a way to use the GrammaticalStructure class without having to download the entire Stanford CoreNLP .jar and adding it to the project as a library? This question applies to other dependencies as well, since I want to use other external libraries but avoid including their .jar files as much as possible (to minimize the size of the final application, given that it will be standalone). Unfortunately, all the solutions I have found proposed exactly that.
Apologies if I have overlooked some basic setting or setup steps, it has been a while since I have worked with Java.
Any help is greatly appreciated.
If you want to use it means you want to execute the code in them. How is the runtime supposed to execute code that is does not have? How is the compiler supposed to know how the code is defined (e.g. what the classes look like)? This is simply impossible. If you want to use the code you have to provide it to the compiler as well as the runtime.
If you just dont want to include all of that code into your application, you need either access to the sources and just pick the class you need or you need some kind of JAR minimizer as #CrazyCoder suggested.
I am learning to use a programming language based on Java called Processing that's basically a library. While it comes with it's own IDE, I find too minimal and basic, so I wish to use Eclipse instead.
While I have been able to get it to work, it's a whole lot of hassle to import the library everytime I start a new project, and I was wondering if it's possible to set some sort of default starting "skeleton" for Eclipse where everything is already loaded and ready to go.
Thanks in advance!
While you can create an eclipse template, it's worth trying the Proclipsing Processing plugin.
On top of creating Processing projects it makes it easy to manage/import Processing libraries and (hopefully still) generate applications.
I'm trying to read a .qm translation files with Java.
.qm files are binary files. I don't have access to the .ts files.
And I don't find much info on these .qm files.
How are they structured ?
Regards,
There's no documentation that I know of, but if you look at QTranslator::load you should be able to follow the format of the QM file.
You will probably need to reimplement QTranslator in Java, as you need not only the ability to load the files, but also to extract and apply translations in Qt fashion.
As per request of OP:
You could use those files by using the Qt libraries and JNI. By using the translator in a c++ dll you can translate strings easily. However, you cannot extract the files or list the contained translations. But if all you need is the actual translation, this solution should work.
I cannot give a real example, because I only now how it works in theory, I haven't tried it, because it's not trivial. But if you are eager to try it out, the general idea would be:
Create a C++ dll and build it against QtCore. The easiest way is to download Qt from their website qt.io. You can for example create a default library project with QtCreator. Note: Besides Qt5Core.dll, Qt requires other libraries to correctly run. They are all included in the installation, but once you deploy your application, those of course have to be includes as well.
Include JNI to the C++ project and link against it. if you're new to this, here is a nice tutorial: Java Programming Tutorial
Create your wrapper methods. Methods in cpp you can call from java that take java strings, convert them to QString, translate them with QTranslator and convert them back.
Load the library in Java and execute those methods
Important:
First, I don't know how java handles dll dependencies. If you encounter errors while loading the dll, it's probably because dependencies of your dll are not present. Second, Qt typically requires a QCoreApplication running in the main thread for most of it's operations. I tested the translator without such an app, and it worked. So apparently for translations only the app is not required. However, depending on what you do in your dll, I think this is important to know.
If you need more details, feel free to ask.
I made a small project using Scala (SBT + IntellijIDEA) that provides me a set of classes and other functions that I want to use in Android. I will call this project $core.
So, keeping that in mind I tried to first only use scala. I tried to create an Android Project using android-plugin and I got it.
But what I really want is to use my $core in an Android Project AND expand the $core classes using Java. $core provides an API that I would like more people to use and they probably don't know Scala so Java would be perfect. Besides, I need to go into a safe route with Android. I saw some info that scala takes a lot of time to compile into Android and has some limitations (like with parceblles).
I already tried to use the classes in eclipse with the import class folder option. I even tried to generate a jar so at least I would have a way to run it and no success. Always the NoClassDef error when I try to use one class from the $core. I have tried to import also the scala compiler library, but didn't work out aswell...
Core isn't finished yet and I would like to develop on a single environment that allowed me to debug on the android device. How can I setup all of this?
PS: Changing to eclipse now maybe is better? Never tried android on intellijIDEA and In scala I can't debug over there, at least using ScalaCheck...
Is it possible that you are getting an noclassdeffound error when working with Scala code from java because you didn't add the Scala library to the java project or at least included the party of it that it's used in the Scala code in the jar?
Could you post the rest of the error?
You could package the core to .jar together with Scala library, use Proguard to remove all unused Scala library classes from it, and then use that jar as a regular library.
I'm a fan of a fairly big open-source program which is written in Java and uses Swing as a front-end client on series of web actions. As I've been working with Android development for a few months, I had an idea that I could create a new app that works similarly to the Swing application. The program is well-organized and separates interface from implementation, also offering a command line interface as well as Swing.
So ideally I'd like to be able to just inject a new Android package into the existing file system somewhere, make use of the back end that already exists, and have it work seamlessly with new updates to the program. The closest suggestion I found was this:
Q: How can I create a new project from an existing project, using Android command line tools?
A: Copy the directory tree of the old project into a new project.
This doesn't seem like it can be feasible advice for me, since I have to work with the existing SVN repository rather than starting the whole thing from scratch. Is there any way to pull this off?
since I have to work with the existing SVN repository rather than starting the whole thing from scratch. Is there any way to pull this off?
I doubt it. Android won't like the Swing code; standard Java won't know what to do with the Android code.
I suggest that you reorganize your code base into three:
One generates a JAR file, containing the common logic
One is the rest of your existing Swing/command-line logic, which uses the JAR
One is a new Android project, which also uses the JAR
Maybe you can pull this off by having src-jar/, src-swing/ and src/ (latter for Android) and associated build scripts. Personally, I'd have three totally separate projects.
Since SVN supports move operations (at least, it used to, last I used it, oh so many years ago), you should be able to accomplish this reorganization without losing any version history.