I want to develop a Java application mixing java with jython. I am using the IDE Netbeans with the python plugin. How do i work on this? (There is a built in support for Groovy with javaSE from IDE call Groovy classes from Java code, and Java classes from Groovy code but not for jython)
ref: http://www.netbeans.org/features/groovy/index.html
Netbeans 6.5 supports both Python and Jython.
http://www.netbeans.org/features/python/
Assuming you are using that version with the Python plug-in, it's just a matter of setting the runtime you wish to use via the platform manager (here's where you would choose Jython).
alt text http://img15.imageshack.us/img15/1586/platformmanager.png
I would also want to add that since 6.5 release, the Python bits have been vastly improved upon. So, if you want to try the new but unstable builds, please grab one from http://deadlock.netbeans.org/hudson/job/python/
Also, please refer to various documents linked from http://wiki.netbeans.org/Python and my blog posts at http://amitksaha.blogspot.com/search/label/nbpython
In case of problems, please let us know on the mailing list.
If you want to develop a Java application that blends with Jython and works outside NetBeans, then NB's ability to use Jython runtime doesn't help much. Instead, you have basically two choices:
You can compile your Python to Java classes using jythonc.
Or: you can embed the Jython interpreter inside your Java app.
To embed, you need to create a Jython library to be included in your Java app. Do this by going to Tools -> Libraries, select New Library, and add the stuff at NetBeans' Jython directory there (C:\Program Files\NetBeans 6.5\python1\jython-2.5 in my machine). You need jython.jar and at least most of the stuff at the javalib directory.
Related
I recently downloaded VS Code for Java development. When I initially opened an existing Java Project in VS Code, it was unable to identify objects from the Selenium library. I downloaded the Java Extensions plugin and a few others, and now VS code will not recognize any of my imports as valid. Javax and Java.swing are among the now undetectable libraries. Is there a setting I missed? What do you recommend?
VSCode just an Editor, after you install some extensions, it only makes the editor more convenient, get more abilities even can help you develop the project of some kind of language through combine with the language support in your computer. Such as, you need to install JDK, then to install the 'Java' extension, then the extension to combine with the JDK and the VSCode, then you will get the ability to develop java project in VSCode.
That's means, The 'Language Support for Java(TM) by Red Hat' has nothing to do with java development. For example, after you install the JDK on your computer, you can develop java projects in the other IDEAs such as Intellij IDEA or some others. The 'Language Support for Java(TM) by Red Hat' extension just to combine the JDK with VSCode better, to make VSCode better to develop java project.
As you said, you failed to import libraries. Of course, the 'Java' extension without any libraries of java. You need to configure it by yourself. In the Explorer panel, you can find 'JAVA PROJECTS'. In it, you can find which libraries you have referenced and you can adds libraries in it. And of course, you'd better take maven to manage your project.
By the way, recommend you to install 'Java Extension Pack' extension.
You're going to need to add support through extensions because by default VS Code does not support Java. The great thing about this extension is that you get a slue of other extensions as well, such as; maven, debugging tools, support for junit, auto completion, etcetera.
On a side note, you could always use an IDE/IDEA like IntelliJ, Eclipse, or likewise. I'm definitely partial to IntelliJ but they all have their pro's and con's.
I am working on some Forms and Report Builder written in Java which can run on Android as well. At least the Forms and Reports executer. Users can enter simple groovy scripts, which can change simple variables. Now my problems is that groovy won't really work on Android. Is any way that I use instead of Groovy another language.
Requirements :
- that language should be compiled and executed in Java
- pass and read variables to the scripts
- the resulted bytecode should run on Android as well, or eventual directly compiled and executed in Android
Besides tim's variant(SL4A), there are several more java vm's for existing scripting languages.
Be carefull, not every one will serve your purposes, as Android hasn't JVM, it has Dalvik VM instead, wich works differently, and pack and optimise java bytecode, when some JVM scripting languages relay on dynamic class files compilation and execution.
If your tasks are simple, consider Lua. It's an extremely lightweight scripting language, and it has a 2 working pure-Java vm implementations, which will go on android:
http://sourceforge.net/projects/luaj/
http://code.google.com/p/kahlua/
Version 2.4.0 of Groovy will have Android support.
At the time I'm writing this, the current version is 2.3 and there's still no public beta of 2.4, but you can try right now by building the snapshot like this:
$ git clone https://github.com/groovy/groovy-core
$ cd groovy-core
$ ./gradlew clean dist
the generated library to be included in your Android Studio project will be target/libs/groovy-test-2.4.0-SNAPSHOT-grooid.jar.
Then you'll need to modify your gradle.build file to include Groovy support; this system looks still in early stages, so please refer to this page for further info: http://melix.github.io/blog/2014/06/grooid.html
I am trying to recompile an existing Java project exported from Eclipse. It is necessary to recompile this because I am running simulations remotely on other machines where a different (older) version of Java is installed. I have tried recompiling my .java file which specifies the simulation in question. However, it appears that it is necessary to recompile all other classes etc as well. Has anyone got an idea how to do this WITHOUT using Eclipse (I am not the Admin on the other machines and thus Eclipse is unavailable to me) and not manually because the project is quite huge?
Thanks a lot for any suggestions!
I recommend you to always have an command line way to build an application. The usual way to do this in Java is using ANT (or Maven).
As #Santiago Lezica says, Eclipse can generate an Ant file.
I believe that Eclipse allows you to build for an older target platform than the one you are currently running. That way you can do all of your builds locally.
The second approach has the advantage that you can fix any problems arising from compiling for the older platforms (e.g. use of new language features, use of new classes / methods) from the comfort of your own ... workstation.
There is another option that you should consider: Tell Eclipse to generate code for the old Java version (see the compiler options). That way, you can create code that runs on Java 1.3, even if Eclipse uses Java 5.
Not sure what your requirements are, but you could set the compiler level for your projects at the (older) level of your Linux installs. This would cause Eclipse to recompile it at that version, instead of a newer version.
At my company we use IBM's Rational Application Developer (instead of pure Eclipse), but I am assuming the option is in the same spot. If you right-click on your project, you can go to the Java Compiler options and then set the compatibility to the level of that on Linux (1.3, 1.4, etc.).
Since compile Java byte-code is supposed to be portable (for the most part), this should get you past most of your problems.
Otherwise, the other option is to use something like Ant or Maven scripts (which can be kicked off by Eclipse) and then just use a property to set the compiler right before you run it. This way you don't have to switch properties on your projects all the time, if you truly do need "newer" compiled code and can't live with "older" code on both systems.
I have a java program consists of a jar for the "real program" and a sub-folder containing 20 jar library files (also have dependencies between them). I tried but without success ... I'm missing with the many options that gcj to compile :(. Does anyone know how to compile to native code so that a java program?
Thanks
Update: I have used the plugin for Eclipse (I'm using the 3.6 version of Eclipse and the plugin works well) http://gcjbuilder.sourceforge.net/ to generate a Makefile for the compilation. But now I have an another problem :(
Some libraries are not compiled (exit for error). The error is that GCJ considers all .class files inside .jar file, that have dependencies with other libraries do not exist. But for the purposes of my program, these classes are not used (that is, the java program it works properly). There is thus a way to force gcj to consider only the classes actually used in my java program?
I can only recommend that you don't use GCJ. It isn't Java. The compatiblity matrix on their web page is far from encouraging. It doesn't implement Java 1.2 completely yet, let alone all of 1.3, 1.4, 1.5, 1.6. The project appears to be falling further and further behind, and it never had 100% Java compatibility as a stated goal in the first place.
You may want to look at tools like autojar and firends to help resolve your dependencies and to make a single jar.
I am working on an application called Enchanting. The application, based on Scratch, emits Java source code and compiles it for uploading onto LEGO Mindstorms NXT Robots.
While the application is very early, users have a hard time installing it.
Right now Windows users have to:
download and install a Java Developer Kit
download and install LeJOS (a java library for the NXT)
possibly tweak environment variables
then they can download, install, and run Enchanting itself
If I could provide an installer that would include the JDK, and LeJOS, I could figure out the environment variables at run time, and the process becomes:
Download, install, and run Enchanting
Is there a way to redistribute a JDK?
(Incidentally, Processing (a simplified text-based programming environment) seems to offer a version that comes with the JDK, so it appears that there is a legitimate way to do so).
Addendum: I would like a Windows user who does not have java installed to be able to run a single .exe file to install the JDK, LeJOS, and Enchanting.
The information regarding redistribution is here for Java 10 JDK and here for Java 8 JDK. Currently Java 8's is substantially more detailed than Java 10's.
and you can use PackJacket, to package all the files you need and create an installer.
Assuming you satisfy all the legal terms required to distribute stuff, you can use izpack to install all the prerequisites, including a JDK/JVM and configuration of environment variables.
Quite a number of IBM Eclipse based tools have JDKs with them.
Or you could just emit bytecode directly. You could bundle a much smaller (than the JDK) JVM dynamic language then use it to compile to bytecode or use libraries made for that purpose.
(I got the following from the Projects using Kawa page)
App Inventor for Android uses Kawa to translate its visual blocks language.
...The Nice compiler (nicec) uses Kawa's gnu.expr and gnu.bytecode packages to generate Java bytecode. ...
It's this last one is the one that uses the Kawa language framework to generate bytecode.
Don't forget about Groovy, Jython, Clojure, and Ruby. Interesting fact about Groovy, the interpreter can compile Java code since Groovy is (more or less) a superset of Java.