Running Java on Flutter Web/Desktop - java

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

Related

Can i use the api java 'jena' in flutter mobile application

I want to create application mobile with flutter but i need api java which is jena, so can we use library java.. In flutter if yes, so how?
You could use platform channels to communicate with native interfaces of your app, but looking at the library, that's probably not a good idea.
More drawbacks:
You have to implement native code twice, for Android (Java/Kotlin) and iOS (ObjC/Swift). That means an app depending on Apache Jena will only work on Android if you don't find a counterpart that works natively on iOS.
All communication through platform channels is asynchronous, which increases complexity.
When the API of the java library is complex, you end up duplicating a lot of code.
If your app heavily depends on Apache Jena, you have a few options:
Create a Backend Service in Java that does the processing which requires Apache Jena. Send the result to your Flutter client.
Write a native Android app that directly uses the library. Drop iOS.
Port the parts of Apache Jena that your app needs to Dart (probably too complex)
You would need a Flutter plugin that exposes the Jena API to your Dart code base over platform channels.
The bad news is that at least as of November 2018, no such Flutter plugin exists as yet.
The bottom line is that, yes, it's technically doable, but you would need to create the plugin yourself or motivate somebody to create it.

examples for controling gradle via java api?

I'm looking to integrate Multi-OS engine with my scala libgdx app.
Currently, I have scala-libgdx set up (from https://github.com/charafau/scala-libgdx.g8), but it's missing the iOS part due to discontinuation of robovm.
Of course, there's sbt-moe(https://github.com/HevyLight/sbt-moe), but the author has not yet answered my email for help understanding its usage.
Anyway, back to the point: is there a way to 'control' gradle via some java interface? If so, are there any examples running around?
ps: I'm thinking about controlling gradle from sbt

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.

Wrapping the whole C++ application to 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.

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.

Categories

Resources