How to Launch REPL using java Swing application. As shown in Image. This REPL should be able to run all functions provided by Clojure Build-in libraray and other developed libraries by user. (provied as jar in classpath).
Point is, how to run Java clojure.jar clojure.main from swing so that it will show user defined Namespace. like myRepl=>
I'm not sure I understand your question exactly. Do you want to write such REPL or to just use it?
In any case, googling for "clojure swing repl" seems to show interesting results, one of which is: https://github.com/alandipert/clj-swingrepl
N.B. I haven't tested this.
Related
I have two questions, this could go into different directions based on opinion, but as of right now I am writing a Java/Kotlin API. So far it is compatible across all platforms, excluding IOS(have not tested).
A few of the tasks it runs is python using PY4J but the way the API calls the python script to start the PY4J connection is
Runtime.getRuntime().exec("python script.py") # Is there a better way to do this?
Which is fine until it comes to Android. Will Android be able to use this method? If so, the question is answered and finished there.
If not, is there a way to embed a python interpreter into a JAR file? Java project?
I like Jython, but I could not get NLTK to work with it.
1) Is there a way to make Jython work with NLTK : If not,
2) Is there a way to use PY4J in Python?
3) Is there a way to embed a custom Python interpreter in Java/JAR?
Feel free to edit my question, code and title. I don't do this much, so it is probably sloppy.
This was silly, but I will keep it up since this was a real question. You can install python3 directly into the JAR. When the python installation screen shows up you can just install it into a folder inside your Java project.
For the Android part, there is a python package called p4a, python-for-android. You can create a python interpreter with dependencies. This should work.
I'm looking to get started with javafx and fxml, without downloading netbeans (as the official docs suggests: https://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm), eclipse or scenebuilder. I'm looking to use a simple text editor and terminal, similar to the way someone might create an html,css and javascript project. Is this possible, or is the only way to use fxml and javafx through netbeans or some other similar tool?
Technically speaking, in any programming language, IDE is always optional.
You can write all your source codes (.java, .css, .fxml) files using any text editor that you like (like Notepad++), then go to a command-line interface (i.e. terminal, command prompt etc) and compile them, pretty much like how you would compile a Swing application.
The advantages of doing so? Pretty much simply because you can do this without any unnecessary downloads.
The disadvantages? You have to be VERY VERY clear on every single details about Java and JavaFX.
You need to be extremely familiar with building and compiling Java applications manually. You need to do your own build path in order to compile right.
There is nothing there that will instantly tell you that you have made a mistake (be it minor or major, or even a typo). You will only see where went wrong after you re-compile via command-line.
You have to do your imports manually (in both java and fxml). This means that you would have to know the exact package names and class names.
Most of the time, you would have to imagine how your application would look like visually. The only time if you know you designed right is when you re-compile and run it via command-line.
HTML, CSS, Javascript are considered scripting language. This means that these codes do not require code compilation, and that there is a base application/process that is running in the background to interpret what you wrote in English terms (or at least it is very close to English).
Languages like Java are true programming language, they require you to compile them, and running them will most likely create a new process on the OS.
So the conclusion is, it is definitely possible to do so, but you would probably end up using 10x (if not 100x) more time doing the same thing. IDE is there to help you do some of the tedious things. If you really want to do it using the traditional command-line method, ask a new question on that.
I have seen in answered here that if you want to call a python script from java, you can use jython as a option.
But have seen other answers as well saying, you can use Process or ProcessBuilder and call their exec or start methods to run the python script.
As I understand jython allows you to program python in you java code, but it allows you to call python scripts as well via, PythonInterpreter.execfile.
So I'm wondering what are my options if I want to call a python script (e.g. text processing script which uses nltk) from my java code and along with some arguments and return the results back to my java programme? which option should I use?
Jython is an implementation of the Python language for the Java platform
(source)
You can simply use ProcessBuilder if there is a regular python script on a machine that has regular python installed. This saves you from having to include a whole python runtime in your java application. You can pass parameters quite easily, the returned text is a little trickier: See http://examples.javacodegeeks.com/core-java/lang/processbuilder/java-lang-processbuilder-example/ or other examples. Basically anything that the python program prints can be captured that way.
However if you don't like external dependencies and prefer shipping everything in a single application you can try jython. It has some limitations though since it doesn't come with all those modules and it seems it may have difficulties with C modules. Getting Python's nltk.wordnet module working for Jython looks like an explanation on how to get nltk to run with it. Arguments and return values should be simpler with jython since the integration is better. And if you want more than just printed text, Jython can even call into java code directly from python. That would give you interesting options for hybrid code.
I have a java library that generates a report given some simple input parameters. Currently its a console app. I wanted to create an extremely simple UI for this. What is the quickest way to achieve this ? Are there alternatives other than embedding this library in an application server and then creating a web server that will call it to get the results.
If you are using Eclipse, you can use SWT, WindowBuilder plugins.
http://www.eclipse.org/windowbuilder/
http://www.eclipse.org/swt/
Why a web server? Creating simple GUI with Java's swing is simple enough, and it'll allow you to use the library directly.
Another option is to write a simple GUI application that'll run the console application you already have. If you are using Windows I recommend using HTA for the GUI, and WScript.Shell.Run for running the console application. If you are using Linux, you might want to check out node-webkit and use the child_process module for running the console application.
I have created a Greenhouse Monitoring system using SunSPOTS. The code modules are written in java.
The problem I face is that I need to run these programs using ant commands. Im able to do it through a terminal independently but Im unable to find a way to build a gui and execute these modules through that.
Any kind of help is welcome.
Thanks
Take a look at this links this might help
http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
http://ant.apache.org/manual/Tasks/java.html
If i understand the problem correctly, then what you need is a way to call your ant script from java ui (may be some button or link). You can use Runtime.exec("cmd ant targetname") to call ant script.
you need to provide more details, f.e. what kind of GUI ? Web based, Java Swing, Applet ... ? Note that most IDE's (Eclipse, NetBeans,IntelliJ ..) have ant support, means write and start ant scripts. What platform ? If you need a platform independent mechanism maybe Groovy is for you; so f.e. build your swing gui with Groovy swingbuilder and start your ant logic with Groovy antbuilder