Wrapping the whole C++ application to java? - java

I currently work for a company which gave me an application implemented by a former student. They completely wrapped (even the main) an existing C++ application with SWIG.
The application was first designed to work on a desktop and now they want to make it work on an android phone.
My questions are:
Is that possible for the application to work knowing they didn't succeed to wrap all
the libraries?
Is there another way to do this?
Is it necessary to write the main in Java and call the C++ libraries?
Any idea will be welcome!

I have doubts about there is a automatic utility like SWIG will work to convert PC -> Android - Android OS have significantly different architecture.
Look at Android NDK - it is a development kit supporting the features called JNI in usual Java applications.
You can include C++ libraries in your Android applications with Android NDK. So it is the way to develop cross-platform applications.

Related

Running Java on Flutter Web/Desktop

I was looking for a way to possibly use a java library of my own inside of my Flutter App.
I did some research but was only able to find information about how to integrate flutter with native Java libraries on Android exclusively.
Is there a way to call on java code also from Flutter Web and/or Flutter Desktop?
I am sorry I can't provide further information to this question as I was not able to find any "lead" if not starflut (https://pub.dev/packages/starflut) - which to the 'beginner' programmer I am in Flutter might seem an overkill approach to this problem - and I'm not even sure it supports Flutter Web/Desktop as of yet.
Any help, comments or ideas would be highly appreciated
EDIT 1
As implementing Java on Flutter Web seems close to impossible (or not worth the hassle), would calling C++ libraries from Flutter Web be a possibility?
EDIT 2
To better describe my problem/situation, I'll add some context.
I need to write a library that can be accessed by multiple flutter apps (both Web and possibly Mobile, but PWA would also be ok), but also by multiple programs which don't use the flutter framework.
I considered a couple of options, but I am still quite inexperienced and I am not sure which way to go forward with:
C++ as the core of the library, and making language bindings to Dart
It seems C++ code can work on mobile, but I haven't found a way it can be run on Web as well as within Flutter
JavaScript as the core of the library, and
either accessing the library directly from Flutter Web (seems to be possible https://medium.com/flutter-community/using-javascript-code-in-flutter-web-903de54a2000 )
Though I am not sure if this solution would work also on Mobile Flutter
Using Dart itself as the core of the library
this would be the quickest option when rolling out the Flutter App(s), but it would also have the drawback that I'll need to rewrite the library in another language later on
Calling c++ from flutter web is not possible. You can, however implement whatever functionality you want in the server-side using whatever language you want and expose the functionality to flutter using whatever web API you desire. You can follow the same approach with Java, and it doesn't have to be just web. The requirement though is that whatever you're implementing has to reside on the "server" which the system can run freely. Your flutter app just "connects" to it and sends and receives messages

how to use java based project in firebreath plugin framework

I am trying to develop a HTML5 plugin using NPAPI and firebreath framework. The code which needs to be used, is written in java but I need to convert it into C++. The only way i know is via JNI where i need to convert each .java file into .cpp file. However there are over 200 files in my project. Is there a better way to achieve this??
Any "simple" way would be more of a c++ question than a plugin or firebreath question. My guess is that you'd be far better off just making it an applet rather than a plugin if you want it mainly in java. There is nothing that I'm aware of that will make it easy for you to do what you want to do using FireBreath or NPAPI directly.
JNI doesn't convert Java to C++, it is a technology for calling native code (such as C or C++) from Java code. It doesn't seem relevant to your problem: Either you (manually or robotically) convert all your Java to C++ (which you can then call from Firebreath), or you keep your code in Java and run an applet (with no C/C++ code involved.)
If an applet as suggested by #taxilian isn't a good choice, why not turn your Java project into an application, and have your Firebreath plugin launch that and communicate with it? Your plugin could even download and install the Java app, for example in a temp folder. One limitation: The Java code won't have any direct access to internal browser API's, the Firebreath plugin would have to make any such calls on behalf of the Java app. How hard this all is would mainly depend on the complexity and bandwidth of communication needed between the web page and the Java code.

Can I use Ruby or Python library in Android Java application?

Let's say I want to write a poker app for Android.
It is fine to use APIs in Java. But when it comes to heavy usage of arrays, sets, combinations etc Java becomes a huge pain for me. It's much easier to code poker AI in Ruby/Python IMHO.
So the question: is there a way to use either Ruby or Python functions in Java Android Application? It should be packed in .apk of course.
UPDATE: Regarding Ruboto: As I understand from this link https://play.google.com/store/apps/details?id=org.ruboto.core&feature=more_from_developer#?t=W251bGwsMSwxLDEwMiwib3JnLnJ1Ym90by5jb3JlIl0. ruboto-core needs to be installed on device to run ruboto apps =( It's no good if I'm going to share my app on Google Play.
How about JRuby? It's an open-source implementation of Ruby on top of Java that lets you use the JDK libraries. You could embed a JRuby instance into your app and run your logic using that.
Also see Jython
Have you tried Ruboto?
It claims to run Ruby scripts in Android devices!
There's this that might help you though, scripting Layer for Android SL4A found here, Though am not sure exactly how you'd integrate it with Android SDK :)
Actually, on reading the wiki, in the FAQ and quote:
Can I use SL4A to write a real Android application or embed SL4A
scripts in my application? Yes! You can embed your script in a
(mostly) stand alone APK.
Here is python-for-android, which let you include a python distribution in your android application, the distribution could include module you want to use.

Java vs native coding in Android Application development

I plan to create an SDK (involving huge data manipulations), which can used to create applications on Android.
I plan to develop the complete SDK, including the libraries in Java, for the reason that if I implement my libraries in the native language(C++) the data movement between the Java and the native layer will involve memory copies and will make my application look slow.
I plan to port the same SDK later to other platforms like Windows Mobile. I am a bit confused on the better approach to code in such cases, keeping in mind the portability and performance of the SDK.
Inputs will be greatly appreciated.
Windows Mobile supports native code (Visual C++, see Getting Started in Developing Applications for Windows Mobile) so using the Android NDK would be a good option. At least you wouldn't have to write the whole thing from scratch. You could have the common code base written in C/C++ and only write the Java wrappers for Android.
As you know, Windows Phone 7 (the successor to Windows Mobile) uses C# and whatever approach you take on Android, you'd need to rewrite the SDK from scratch anyway. Windows Phone 7.x might be supporting native code (C/C++) sometime in the future but not anytime soon.

Android class libraries

Android class libraries are written in C/C++ but java is the preferred language for developing applications.Why not C/C++ instead of java ?
If you prefer to develop via C/C++ you may use the NDK. The Android platform is run on the Dalvik Virtual Machine, what you code in java is actually compiled to Dalvik bytecode and run on the VM.
They spent a lot of time developing the facilities to make it fairly painless to make an Android application using a managed language. Some people would consider this an advantage.
There are many reasons to choose Java as the platform, but my guess as to the biggest reason why would be to not expose application developers to a slew of porting issues that arise from the sheer number of devices that Android powers. There would be far fewer apps available if every developer had to research every platform nuance for every phone and tablet out there.
Obviously, there are drawbacks, and that's why the Native Development Kit (NDK) exists. The NDK primarily addresses performance issues, but recent additions have included the ability to write an entire app completely in native code.
Java it's used in many application for mobile devices, it is a standard because it is more manageble, even the new languages that are appearing now it's based in java. It is a open language and you can learn it without going to class. Javame is used for mobile devices which incorporates some features of J2EE and adds new classes for the small devices.

Categories

Resources