Within one of my application logic recipes, I need to use java during compilation time on the host system. The tool needs java 1.8 and fails to work with the jamvm-native and cacao-native packages.
What I have tried so far is to add the meta-java layer to my configuration and add DEPENDS = openjdk-8-native to my application logic recipe. This makes yocto compile the openjdk-8-native just fine.
Then, when I start a devshell for my own recipe java -version gives me
java version "1.5.0"
JamVM version 2.0.0
I can find the correct java from openjdk-8-native within the recipe-sysroot-native/usr/lib/jvm/openjdk-8-native/bin/ directory, but how can I make it the default java in PATH or use update-alternatives to make my build tool pick it up correctly?
Just for clarification: I do not need java on the target, just a native build during build time of another tool. I'm currently using yocto rocko version.
Related
We want to use both SWT and JavaFX in an Eclipse plugin within our RCP application. Unfortunately, we're experiencing problems integrating SWT with JavaFX under Java 11. The build environment uses e(fx)clipse 3.5. We're developing against the Community edition of Azul Systems' "Zulu" JDK 11, bundled with Azul's version of OpenJFX.
Formerly, we developed under Java 8. At that point, our build used a compile-time class path referring to jfxswt.jar, which lived in the jre/lib directory of the JDK. We didn't use any special class path settings at run-time.
We are now trying to move to Java 11. There, this JAR has become javafx-swt.jar and lives in the lib directory of the JDK. It no longer seems to be enough to set the class path to refer to this JAR at compile time: it seems to be necessary to do so at run time too. If we don't do this, we get an error (java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas).
As a test, we experimentally embedded javafx-swt.jar within the JAR implementing our Eclipse plugin. We then referred to it in that plugin's .classpath file, and the code worked as expected. Unfortunately, we can't embed the JAR this way for legal and other reasons.
A note on Java modules: javafx.swt does not show up in the output when we issue the --list-module command. We tried running the application using parameters -p /path/to/JDK/lib/javafx-swt.jar --add-modules javafx.swt, but this doesn't seem to solve the problem.
My question: Is there a way to set up the class or module path to allow our Eclipse plugin to find this library in the JRE? Any solution would have to work with whatever JRE the code happens to be run against (I think it is all right to assume lib/javafx-swt.jar will live in that JRE).
Would it help to use a separately-downloaded version of OpenJFX rather than the copy of OpenJFX in our JDK?
Very many thanks ☺
I am working on a Java test project using Cassandra for persistence and Achilles as my client API for Cassandra. Also, for testing purposes I am running Gradle builds on this project in Drone.io.
The Achilles library depends on Java 7, which is one of the possible types of builds for Drone.io, but since this is a Gradle build, it is necessary to make it a Groovy build. According to this official doc page, it should still be possible to use Java 7 inside the Groovy JVM with just an additional command in the build script in order to change from the default 1.6 JVM:
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
However, after adding that line to the build instructions, I get the following error messages from the Drone.io build log:
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
This is apparently a frequent error for which I managed to Google a number of solutions.
My problem is that all of these solutions involve installing plugins and/or adding entries to the sources list, which doesn't seem to be very straightforward in the Drone.io virtual machine.
One solution was running sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/libnpjp2.so 1 (I updated the path from the original solution in order to reflect the VM's directory structure) to install the missing lib, but there is no libnpjp2.so file at this location in the VM.
Has anyone had better luck using Java 7 in Groovy/Gradle builds in Drone.io or has any idea of a workaround?
The best way to use Gradle with drone.io (and even in general) is via the Gradle Wrapper. This works with any drone.io build type, so you can simply select Java 7.
My application will support only java 1.6 version and I need to execute all test cases using java 1.7 compiled class files code.
My question how to reach above requirement...
Is it possible to install both java 1.6 and java 1.7 versions in my machine?
If possible how can i set java 1.6 path for my application and how i can set path for java 1.7 version to execute test cases using java 1.7 compile files.
Application will not open with Java 1.7, but I need to use java 1.7 compiled files only.
Yes , it is possible. You need to change JAVA_HOME environmental variable. You can set it in the script that is used to start the application.
This article might help you
Yes it is possible.
You can install multiple java versions in single system.
To make it simple. You can use eclipse , or Netbeans IDE. In that you can use different java versions to compile.
Like any program, you need to specify the directory of the program you want to run, either directly by giving the full path name, or indirectly by setting an environment variable like PATH or JAVA_HOME OR JDK_HOME
You can install any number of updates/versions of Java until you run out of disk space. To configure each program to use a specific version you need to look at how they are started and set appropriate directory to use Java from for that program.
I have 2 separate Java installations on my machine. I have 5.0 to support an older Enterprise app I develop on, and I have the latest JVM installed for other things. I need to keep the old version on my machine, but I am now trying to use Play! 2.0 for some of my own projects.
When I try to run it from the Play! directory I get a "UnsupportedClassVersionError" since the 5.0 version is getting picked up. What is the best way to point play to my 7.0 jdk installation? It is important that JDK5 remain the default.
The play executable you run is a launch script that starts sbt with the Java version that is on the path. You can either change the path when you start it, like so:
PATH="/my/jdk7/path:$PATH" play
This assumes you are using some kind of unix shell. If you aren't, you can modify the launch script itself.
If you mean in production as in play start, you can run once you have compiled your application using play dist :
java -jar yourappname.jar
And thus specify the java version, you want to use;
Can I execute Eclipse Java development tools as a standalone process? I need to get Java program's AST structure using Eclipse JDT from another program, and to do that, I need to execute eclipse plugin as a stand-alone process behind the scene.
Is that possible? If so, how one can do that?
Eclipse/jdt and eclipse/ast is nothing more than a jar file, so one can use them to build standalone java application.
Example
I googled to find ASTExplorer as an example to make eclipse/ast plugin as a standalone java project.
The program was targeted for pretty old eclipse (3.0.2), I downloaded the 3.0.2 for Mac OS X this site - http://archive.eclipse.org/eclipse/downloads/drops/R-3.0.2-200503110845/
You need to setup ECLIPSE_HOME classpath variables in Preference -> Java -> Classpath variables
The .classpath has those classpath variables already, you can refer to this post - .classpath contents update in eclipse. As you can see it refers eclipse/jdt(art) jar files. I'm pretty sure one can change the reference to the newest version of jdt/ast without downloading the 3.0.2 version.
As I use Mac, I need to replace the swt for PC with swt for Mac. I could do that in BuildPath/Configure Build path
First remove the PC swt reference.
Then add the correct Mac swt reference.
Compile the example with the eclipse indigo/on mac
When the setup is correct, eclipse starts building the project. You can use Project -> Build Project menu. Then, you can check the application works fine in eclipse.
Generate the executable jar
Export to executable jar file.
You'll get some warnings, but you'll have a jar file.
Execute the generated jar
Just executing java -jar ast.jar doesn't work on Mac, I got a hint from this post.
Running SWT based, cross-platform jar properly on a Mac
In short, you need to run java -XstartOnFirstThread -jar ast.jar
Does it have to be Eclipses's AST? Or is any AST generation o.k.? If it doesn't have to be eclipse, I'd suggest Habelitz open source Java AST Compiler. http://www.habelitz.com/ I'm using it myself for some projects....
Well, of course you can launch eclipse just like any other process : How to create a process in Java
And then the problem becomes relaying the information back to the original process, which gets kind of messy. My suggested approach in this case would probably be to create a plugin in eclipse and have that plugin do whatever it is you think you need the AST for. You can work out messages with command line options to eclipse, or a shared file or something.