I have a main application that is coded with Java, but I want to use Python because the NLTK lib.
I want to know if it's possible do some integration with these two languages. Thinks like passing parameters from Java to Python and retrieving processed data from Python to Java.
Try Jython
From their FAQ site:
What is Jython?
Jython is the successor to JPython. The Jython project was created in
accordance with the CNRI JPython 1.1.x license, in order to ensure the
continued existence and development of this important piece of Python
software. The intent is to manage this project with the same open
policies that are serving CPython so well.
What is JPython?
JPython is an implementation of the Python programming language which
is designed to run on the Java(tm) Platform.
Related
I have a .NET Core (console) app that I would like for a Java app to depend on. Essentially I would like to be able for the Java app to invoke a multi variable method in the .NET Core app and then pass the result back to the Java app. It would be nice if the .NET Core app could be embedded in the Java app. I have previously seen .NET Framework specific solutions to this problem, but since this would only be relevant on Windows, I would like a solution that also works on Linux.
In the past there were some technologies such as IKVM.NET and COM Interop wrappers but the former is defunct and the latter probably wouldn't work on Linux.
Since you own the .net core code, I would take a more modern microservice approach. I would design the .net core app to be a REST API running as a console app listening on a port. I'd have the Java application spin up the console app, invoke the methods passing JSON back and forth and then spit it down when complete.
From my actual knowledge this nuget package JCOBridge is able to do what you are asking for.
Until now it supports linux for x64 architecture.
I tried the templates available on Templates and them works on my Ubuntu 18.04. The same templates works on Windows.
When I search for Java frameworks, one of the popular result is Grails. However, from what I can understand it uses Groovy as the language which is similar to Java. Does this similarity grant me to call the use of Grails as Java-based web application?
This is not about Groovy being similar to Java, but Groovy being a language that compiles to the JVM. So from a JVM perspective, it does not matter if it is Java or Groovy, they both generate .class files. Because of that, Groovy programming can make use of all java libraries , so Grails takes advantage of this to be based on Hibernate, Spring and other Java frameworks. So for me, the answer is Yes, you can say Grails is a Java based web application.
If you are asking this because your hosting company says that it can host Java based web applications, then I think it's fair to say that your Grails app is a java based web application.
From wikipedia:
"Grails is an open source web application framework that uses the Groovy programming language (which is in turn based on the Java platform)". I believe this grants you to call it a java based web application, or better yet, as answered above, a JVM based web application. It is good to realize that due to this you can use existing java libraries with grails, and also whenever necessary use java source code for your development.
My company is revamping the IT infrastructure and systems, so we are at the middle of finalizing the technology for developing the new system.
We have come to two candidates; Java & Python.
The main criteria of the choice is the language must be complete; in a sense that it must be able to use for web & desktop applications development. Java is proven is this field, with many good web framework (JSF, Hibernate, etc) and relatively good GUI library (SWT, Swing).
However, Python looks more delicious as from my personal experience, development in Python is efficient, I could do more with less time (I only have experience in web development with Django). However, as for the desktop application, I have yet find any good GUI library that comes integrated with the IDE as Swing.
Can someone points me the best if possible GUI framework for desktop application for Python?
For Python GUI, there are 3 main options:
wxPython
PyQt
PySide
(PySide is a derivation of PyQt).
For building the interface, you can use wxGlade for wx, and the packaged QtDesigner for PyQt/PySide (Which both can convert the .ui files to .py
All 3 use native OS widgets, so will look right at home.
Despite having more experience in wx, I actually prefer PyQt, as I find it's a lot easir to work with.
For an integrated IDE for developing Python GUI apps, there aren't any (afaik) complete apps, however, I personally use PyDev in Eclipse, which can handle opening .ui files in QtDesigner for you, which you'd save, run the tool to make a .py file, and it'll work pretty much flawlessly.
It is entirely possible to build a SWING GUI application with Python. Look for Jython, which is Python for the JVM. Any pure Python (no compiled C code) libraries for Python will work with Jython including most of the Python standard libraries.
Also, because Jython is a JVM language, it has access to objects provided by Java libraries such as SWING, and also can use the JVM threading model. Multithreading in plain Python is difficult due to the Global Interpreter Lock. Jython does not have that limitation.
If other people in the company are leaning towards Java, then Jython with SWING would be a safer choice because when people say that you should have used Java because Cool Library X is available, you just smile and say that Jython can also leverage Cool Library X because Jython is a JVM language.
I'm currently using the javax.script package for interpreting and executing Javascript code on the fly. Incidentally, this is the same engine used by Mozilla's Rhino JS interpreter.
Question: is there any Java-based Javascript Engine that is faster than Rhino?
In Java 8, Oracle plan to release Nashorn, which is their own JavaScript engine built into Java. It plans to be much faster than Rhino, and aims to be the reference implementation of JavaScript in Java for the future.
See a recent interview about it with Oracle # DZone:
If you are happy to use a pre-release JDK, you can download it here.
I haven't heard of any Rhino alternatives. According to this list: http://en.wikipedia.org/wiki/List_of_ECMAScript_engines, Rhino is the only Java-based JavaScript interpeter.
javax.script is way older (and slightly modified) than the current version of Mozilla's Rhino which you can download from the Internet. Have you tried getting the latest Rhino and using that?
Also depending on for what you're using it and what kind of integration you require, using node.js may be more suitable for you.
I need to use the logic contained in some java classes. I found JNI, but that project seems not updated recently.
Is there a way to use it in a Delphi native application? I use Delphi 2009.
A newer solution than JNI is JNA, which also supports callbacks from (Delphi) DLLs. I found it easy to use.
You could try j-interop.
The technique I should adopt is to build a COM wrapper of java business logic, and using this COM server from delphi throught interoperability.
Delphi can build a type library of a COM server, and you could istantiate the com server using this typelibrary. Type library is simply a wrapper of the server, exposing its interface to be used by delphi code.
The key to communicating with different platform softwares is called "interoperability".
You can find this also in .net versus win32. Tipically delphi code is win32 (exe or dll), and you can build communication protocol between delphi objects and .net assemblies or java bytecode using interoperability solutions.
With Java 6, it takes only a few lines of code to write a standalone web service server which then can be invoked from Delphi.
small step-by-step tutorial, using the free NetBeans IDE and Delphi:
Delphi and Java Integration using Web Services
more xamples:
http://www.theserverside.de/webservice-in-java/
http://www.torsten-horn.de/techdocs/jee-jax-ws.htm#Minimaler-Webservice
Embed the VM in the native code. This worked for me.
An example with c can be found here. http://java.sun.com/docs/books/jni/html/invoke.html
I very much doubt it. Delphi Code gets compiled into an executable while Java code is executed by a Virtual Machine. So unless you launch a complete Virtual Machine inside Delphi code I see no way to easily include the logics.