How to use Intellij's jre in ubuntu - java

I am using Intellij to write code in Java, if I run my software inside Intellij my software works but, if I create a jar file and I try to start it from my terminal it says that the jre version is too old.
My question is, if the JDK includes also the jre and my software works in Intellij, why it doesn't from the Ubuntu's terminal?

Intelij is poiting to a different java version than the one configured in your terminal path.
If you want to keep booth version the same you can look in Intelij Settings to find out which version it is using, then replace the /usr/bin/java link in your terminal to point to the same java binary.
Or, simply folow these step to just update your teminal version: install-java-ubuntu

I dont know anything about IntelliJ but why not just update the system JRE so it is the same as or more recent than the version that IntelliJ uses?

Related

Intellij executes with wrong java version

My Project is set to run with Java 11.
I can build it without any issues, but when I try to run it, it is looking for Java 1.8
Running on Mac OS 12.2.1
IntelliJ Version 2021.3.2
The problem was in the run configuration. I needed to specify the java version as well. Thanks for the suggestions
You have to check the following settings match (for Java 17):
Also if you use maven check that the correct version is set and if not, change them and reimport the project.

The JDK is missing and is required to run some NetBeans modules what should i do to fix

I am new with programing and i wanted to install netbeans in my macbook but i kept having this text " The JDK is missing and is required to run some NetBeans modules Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information.”
That means you need the Java Development Kit (JDK). It is important for running files and develop those. You can download the newest version of the JDK under: https://www.oracle.com/java/technologies/javase-downloads.html
If you already have a JDK installed you must change the config file of NetBeans.

JRE version of my computer

I have two jre in my PC which is running windows 7. When I am running a eclipse project I dont know which version of jre it is calling, so I searched on net for the solution and tried this two things:
In cmd typed java --version and it showed me 1.6.
In control panel, I went it in java control panel and selected java and it showed me 1.7 enabled.
Now, I am confused and how can I change the jre of the system? I want my eclipse project which is running on tomcat to use a specific jre. But I dont know which jre my system is using.
Thanks in advance.
You may check Windows->Preferences->Java->installed to check default JRE that it runs things under.
You may also check property eclipse.vm under the Help->About Eclipse->Installation Details->Configuration.
choose window preferences in eclipse. Select installed jre and add a jre and select an jre you are going to use.
java -version is what a java app on the system will use by default. What IE uses is determined by the extension (Tools->Manage add-ons) you can see the java plugin there.
You can register any jre vesion you want in eclipse using the window->preferences-> installed JRE's
If you are using eclipse, you can set the Java version by going to project->properties->java build path->select the jre version and click on edit.
You can choose the version that you want. Whichever JRE library is displayed in the build path is the version that eclipse is using to compile your code.

issue with java and environment variables on windows

I've got a curious problem. After installing java jdk 6u25 I tested the installation by typing java in the command prompt. Everything worked fine , the console displayed the usage options as expected. This was about 3 weeks ago - I recently reinstalled windows 7 on my machine- Now I would like to get started with the play framework and followed a tutorial. I got a new application with play new but couldn't use play run because of this:
play! 1.2.3, http://www.playframework.org
Ctrl+C to stop
Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly .
The funny thing is that typing java in the console still displays usage options and neither eclipse or netbeans complained about a missing jdk. Nevertheless I checked my environment variables and was surprised to find:
No reference to java at all.
Seriously I got no idea how the console, eclipse and netbeans found my java. As a first countermeasure I once again reinstalled java hoping that the installer might set the path correctly. It didn't. Now I would like your advise: Should I just create the JAVA_HOME variable ? If I do, will further versions of the jdk override the variable to point to the new version or will I have to change the variable manually everytime? What about eclipse and netbeans. I would guess that they have been downloaded with their "own" jdk. If I want to update java on my machine, will it update their versions, too ?
Update:
I set the environment variable manually and restarted the pc. Now everything works fine but I would like to know what symbolic link is. Could you just give me a link in a comment or explain briefly ?
Eclipse and netbeans use a different way of finding your java installation than command line tools likes play, ant, maven, gradle etc.
IDEs may search your registry, guess default locations, or even have the JRE prepackaged with the installation.
Command-line tools usually rely on JAVA_HOME variable. And you have to set that manually.
Should I just create the JAVA_HOME variable ?
There are several tools that use that environment variable, so I'd recommend creating it.
If I do, will further versions of the jdk override the variable to point to the new version or will I have to change the variable manually everytime?
If you install your new Java version into the same folder (or if you create symbolic links), then no.
What about eclipse and netbeans. I would guess that they have been downloaded with their "own" jdk. If I want to update java on my machine, will it update their versions, too ?
That depends on whether the JDK is prebundled and how the configuration is done. I can't speak for Netbeans but in Eclipse, you could add this to your eclipse.ini:
-vm
C:/Java/jre/bin
Note that this is an example path to the bin folder. If you don't add versions there or use symbolic links (see above) then you'd not have to update the path when installing a new version.
It is possible that you have a (older?) java.exe in C:\windows or other common directory.
Make sure that the java you get on the command line is the one you think it is:
java -version

Can I use Java 7 with Eclipse 3.x?

I am trying to config my eclipse (Helios) use jdk 7 to compile my code. I didn't install jdk 7 on my Windows XP. But I include all of the jdk contents with my project. It seems the solution provided in this post doesn't work. Compile java code needs JDK. the JRE is enough for running the compiled code. I think we need a way to configure the JDK to be used not just JRE. I tested with a JDK 7 new feature, String in switch, I can compile it in my batch file compile system but cannot use eclipse to compile it.
any idea?
This is what I did to make Eclipse 3.x works with Java 7.
install Java 7 in another machine and then copy the JDK folder into my java application 3rdparty directory (so my machine still use Java 6);
download the Eclipse 3.7.1 from here: eclipse 3.7.1
configure Eclipse by following steps in this post (select 1.7 in Compiler compliance level under the Java Compiler entry);
At least I can use String in Switch now in Eclipse.
Good luck.
Compile java code needs JDK. the JRE is enough for running the
compiled code.
that is right
"But I include all of the jdk contents with my project"
Including those will not change eclipse's compiler behavior. Including files under project build path just makes those classes available for your application development/run-time (or as good as setting CLASSPATH)
Do these :
1 - Install required version of JDK
2 - Choose following menu - Window > Preferences > Java > Compiler - and you will see a drop down to choose the version you want to use.
3 - Read this and this as well.
Good luck for being DBA after 5 yrs. Please consider working on your English as well (no offense please)

Categories

Resources