For my project I want to use SymJava. The README there requires me to install the Java Operator Overloading support. Since I am using Intellij IDEA (Version 2019.1.2), I tried to follow the directive given. However, I am confused by the second step:
Add javac8-oo-plugin.jar as compile or processor library.
What is meant by "compile or processor library"?
Also a note: I did the first step before. This made Intellij IDEA ask me to restart the IDE. When I did that, a fatal error initializing the plugin occured when re-opening the IDE and my project:
What may be my misunderstanding in the process? I am using Java 15.0.1 here. Is that the problem perhaps, since it says something about using Java 8? I assumed it should work with later versions nevertheless.
Since I need to use this newer Java version, is it impossible for me to use SymJava then? And if so, can you recommend an alternative library similar to this (which is a Java counterpart to SymPy)?
Add javac8-oo-plugin.jar as compile or processor library.
Means that you need to add this jar to the module classpath by adding it as a module library. This will add it to compile classpath and to processor path if you have the Settings (Preferences on macOS) | Build, Execution, Deployment | Compiler | Annotation Processors | | Obtain processors from project classpath option enabled.
a fatal error initializing the plugin occured when re-opening the IDE and my project:
Double check the plugin zip archive file is not corrupted and is compatible with this IDE version. Btw I was unable to download it from github from the README instrucitons. You may need to better contact the repository author about this.
I finally came to the conclusion that SymJava is not suitable for any Java version above Java 8. This is, because SymJava uses the "java-oo" library. Since java-oo only supports Java 8, it's not possible to use SymJava, either.
The current solution is to use a different library, like Symja, which contains similar features while also supporting Java versions later than Java 8.
Related
UPDATE: Looks like it's not possible yet: https://youtrack.jetbrains.com/issue/IDEA-240044
I'll update the question with an answer, once this issue is resolved (this way or the other)
I have a super-special version of the JDK customized to compile and run a desktop client I am providing as an IntelliJ project (with source).
Users of my client can't get it to work with the Java they have installed on their work stations by our corporate IT.
On the other hand, they need that standard Java to run other things. The custom JDK is not good for running the other Java applications our corporate requires (so, I can't just have my JDK as their system-wide JDK).
Also, the work stations of my users do not support containerization.
So, I am thinking to bundle my JDK with the project and configure it to use that SDK. This is going beyond just preparing a "setEnv.bat" script with "JAVA_HOME=/xjdk" for many reasons, like being able to debug using the IDE, when the IDE is debugging code compiled with the special JDK...
I know IntelliJ has places to set up the JDK and JRE but not sure how to do this in a "relative path" way and such that will run on both Mac/Win without them having to configure the project for the absolute path of the bundled JDK?
Assume the project structure is something like this:
ProjectFolder
|_ src
|_ xJDK
What IntelliJ/Maven elements do I need to set to get both compile and run using xJDK?
Does the version of Eclipse affect the version of code? Suppose, developers are using different version of Eclipse for same version of code with same version of JDK. Will it cause any issue?
No, the version of Eclipse does not matter.
Eclipse has extensive configuration for exactly which version of Java you are targeting. For example see the 'Java > Compiler' settings in the Preferences, and the 'Compiler Settings' in the Properties for a Java project.
You can also tell Eclipse which JRE/JDKs you have installed (see the 'Java > Installed JREs' page in the Preferences). You can run your code using any of these JREs, this is completely separate from the version of Java you are using the run Eclipse itself.
You do need to run a version of Eclipse which understands the version of Java you want to use. So for Java 13 you need to use at lease Eclipse 2019-12.
Of course newer versions of Eclipse contain more tools for helping with Java development and more bug fixes so using an up to date version is recommeneded.
Eclipse is simply an IDE (Integrated development environment). It combines debugging, compiling and other convenient tools for development. on the other hand, the Java code itself is separate, and you don't necessarily need eclipse to write the code. In fact, a simple text editor is enough. All you need is a file with a java extension (Example: hello.java).
It depends on what users share. I'm assuming you're using some sort of SCM, in which case the same project (fully shared) on different versions of the IDE can possibly lead to annoying situations.
There would be no issues in general, as far as producing the code is concerned, except in situations where some versions of IDEs don't support the required Java version (or other features). But I see this more as the user being affected rather than the project/code.
Here's what you should keep in mind:
Keep IDE project configuration files (such as .project, .settings, .classpath) ignored by your SCM system
All Java configuration should be based on a build tool. Use Maven/Gradle, etc, and any modern IDE will be able to create a project from its config file. The IDE would derive local configuration files which should not be sent back to shared repositories
This way, all developers are free to use whatever IDE (and whatever version) without causing interference, and CI tools will work off build tools' configuration as well.
I'm rather new to IntelliJ IDEA and Grails in general. I just started a new Project, selected my project JDK (11.0.1) and Gradle distribution (4.10.2). Whenever I try to run the project, I get this error:
Error initializing classpath: Could not determine java version from
'11.0.1'. java.lang.IllegalArgumentException: Could not determine java
version from '11.0.1'. at
org.gradle.api.JavaVersion.toVersion(JavaVersion.java:68) at
org.gradle.api.JavaVersion.current(JavaVersion.java:78) at
org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
at
org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:66)
at
org.gradle.tooling.internal.consumer.ConnectorServices.close(ConnectorServices.java:53)
at
org.gradle.tooling.internal.consumer.DefaultGradleConnector.close(DefaultGradleConnector.java:57)
at
org.grails.cli.gradle.cache.CachedGradleOperation.call(CachedGradleOperation.groovy:78)
at
org.grails.cli.GrailsCli.populateContextLoader(GrailsCli.groovy:525)
at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:508)
at
org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:306)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:269) at
org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
All other discussions of the problem I found suggested changing the Gradle distribution, which I already did. I would be so happy if anybody could help me out here.
Cheers!
May be your java configuration is not correct. If not correct follow this steps.
Goto File-> Project Structure.
Change SDK
Or gradle version is not matching jdk 11 then skip this answer.
Besides the issue with Gradle above, if you're trying to run a Grails project I don't think you can do that with JDK higher than version 8.
Even the latest Grails (3.3.8 as of this writing) is still based on SpringBoot 1.5 which does not support newer JDK, I don't know if there's a special trick to make it work.
I had to delete the .gradle directory and restart Intellij.
I'm using Eclipse. If I change the compliance level of the main (Android) project from 1.6 to 1.7, I get an error:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.
If I change the compliance level of the "library" (Java) project from 1.7 to 1.6, a lot of the code in it becomes invalid.
Is going through the code of the Java project and fixing every error my single option here?
Google just released Eclipse ADT 22.6 which adds support for Java 7 language features, http://developer.android.com/tools/sdk/eclipse-adt.html. Once you upgrade to to the latest version of the plugin the Compiler compliance level will include the 1.7 option.
Try to clean your project, and fix android properties.
Link here and here
I guess you can find your answer here: Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties
If that doesn't help, I'd suggest to update all android's sdk plugins. I've had similar issue, after updating android's sdk, but I've missed to update android build tools and that caused lot of errors - could be the same with you.
You can use jar builded with Java7 but only in case if it is not using any special features of java7, otherwise dx wont be able to convert jvm byte code to dalvic format.
But there is a one problem: default build process of android sdk (from eclipse e.g.) fails if it finds classes with wrong version (compiled with java7, dx generates warning and fails). You should pass some argument to dx to drop such warnings. Android studio's and Idea's build process doesnt care about this warnings and dx tries co convert java byte code to dalvic despite class version.
Use IntelliJ IDEA instead of Eclipse. In IDEA you can set the Product language level (in Project Structure → Project) separately from the Android SDK's. As long as your code only uses 1.7 features that don't affect the bytecode, it'll work (but the compiler will give you warnings). This way, you can use diamonds, switch on strings, and other syntactic sugar, but you might be out of luck with multi-catch. In fact, you can even use experimental 1.8 features like annotations in strange places, but I haven't tested lambdas yet (since IDEA abbreviates the code anyway). See the intellij-idea tag for more info.
Since Android Studio is a special build of IntelliJ IDEA, it might have the same feature, but I haven't tried in that.
If your library really needs java 7, there is nothing you can do.
Otherwise, go to your library project settings, go to the Java Compiler settings, and select 1.6 .class files compatibility.
If there are errors in your source files, it means your library uses java 7 functions that cannot be compiled in java 6 bytecode. You're screwed.
Otherwise, you can now export a .jar file that you can use in your android project.
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.