Can't find Java JDK in IntelliJ, running Fedora 24 - java

I can't find the directory in which to set up Java as my project JDK in IntelliJ. I tried pointing it to /usr/java/java[version-number] but IntelliJ said that it was an invalid directory. (I don't remember exactly what the folder was called, I just remember it was Java 8.)
I did some googling and found out that it may be because it was corrupted, and they recommended wiping it and doing a reinstall... so I deleted the java[version-number] folder in /usr/java and attempted to do a reinstall by downloading the jdk rpm file from Oracle's website, but apparently I still have the 1.8.0 JDK installed?
When I type in java -version into terminal, I get the following:
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)
I'm not sure where to go from here.

For me the problem was different. I installed IntelliJ's flatpack version of the IDE.
flatpack has restrictions to use the file system.
These directories are blacklisted:
/lib, /lib32, /lib64, /bin, /sbin, /usr, /boot, /root, /tmp, /etc, /app, /run, /proc, /sys, /dev, /var
Exceptions from the blacklist: /run/media
These directories are mounted under /var/run/host: /etc, /usr
So you have to use path something like /var/run/host/usr/lib/jvm/java-1.8.0-openjdk-amd64.
I actually downloaded the IntelliJ Toolbox and installed it from there.

try whereis java maybe it'll show up in your terminal

Related

How do I configure the "Eclipse Temurin JDK with Hotspot" in VS Code after installation by the "coding pack for java"?

I tried installing the JAVA JDK on my laptop, provided by the installer on VS Code website as a "Coding pack for Java". It installed the JDK and the required extensions in VS Code. But then inside the editor, it didn't configure the JDK by itself. So I tried doing it manually and then I found that there is no "JDK" folder in the "Program Files" folder in C-drive. I tried to find everywhere inside that folder about the JDK, searched online at many places, and reinstalled it several times but still, nothing worked. I can't address the error. Please reach out to me if anyone knows the fix for it.
The following java version I tried to install:
OpenJDK version "17.0.2" 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)
Operating system and platform:
OS - Windows 10 pro 21H2 on x64
Platform - V.S.Code
[VS Code can't configure the JDK][1]
[1]: https://i.stack.imgur.com/VU0HH.png
There could be a few reasons why this is happening.
You can check installed Java versions and view their locations by using Registry Editor. There are a few possible keys to check, depending on what JDKs you have installed.
Standard Java -> HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft
Eclipse Foundation -> HKEY_LOCAL_MACHINE\SOFTWARE\Eclipse Foundation
Eclipse Adoptium -> HKEY_LOCAL_MACHINE\SOFTWARE\Eclipse Adoptium
If you want to check using Windows Explorer, some common locations include C:\Program Files\Java, C:\Program Files\Eclipse Foundation, and C:\Program Files\Eclipse Adoptium
If you installed using VS Code's Java helper, then it most likely installed Eclipse Adoptium.
Lastly, you need to make sure that Java is added to your system's PATH environment variable, along with JAVA_HOME (here is how you can do that).
Note that you will need to know the locations of your installed JDK and JRE. That is why I listed how to find said items first.
Hope this helps!

Installing JNLP on Ubuntu for Open JDK 7

How do I get JNLP working for OpenJDK 7 on a Ubuntu machine?
I'm trying to get the source code linked to at http://www.bugaco.com/bioinf/clusterer/ with the text "Download sources" to run on my machine.
Currently, when I try running
javac -cp ".:l2fprod-common-all-7.3.jar:jfreechart-1.0.17/lib/jfreechart-1.0.17.jar" com/bugaco/mioritic/impl/module/project/Main.java
it is giving me the error
./com/bugaco/ui/LoadBean.java:11: error: package javax.jnlp does not exist
import javax.jnlp.FileOpenService;
^
(and many other errors)
which I assume indicates that I need to install JNLP, along with other packages I'll have to install when I get JNLP fixed.
Based on Mike Clark's answer https://stackoverflow.com/a/12608844/38765
I assumed that "Demos and Samples" is the way to install JNLP for Open JDK 7.
I'm on Ubuntu, so I'm trying to use the "Ubuntu way" to install it. I installed openjdk-7-demo , which describes itself as "Java runtime based on OpenJDK (demos and examples)".
It's still giving the error described above. What have I done wrong, or forgotten to do?
I tried browsing the tag wiki for java. The only non-video resource that looked relevant to me in "Beginners' resources" was "The Java Tutorials". The only link relevant from there was "Learning the Java Language". It had a section on packages, but that's only on how to create your own, rather than how to install other peoples' packages.
I'm using Ubuntu 12.04 (precise) 64-bit, and Java 7
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
If you want to use JNLP with OpenSDK, you need the IcedTea implementation of JNLP.
In Ubuntu, install the "icedtea-netx" package.
The libraries you need will be in /usr/share/icedtea-web/.
Just use $ javaws xxxxx.jnlp .
It works to me on :
(open-jdk-7 + Ubuntu 14.04)

Java -install vs PATH

I am new to Ubuntu and trying to install a particular version of java.
I downloaded the jdk1.7.0_51 binaries in my Ubuntu machine and exported the variable JAVA_HOME='home/programs/jdk1.7.0_51 and the PATH=$PATH:$JAVA_HOME/bin. However when I type java -version in the command line I get:
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
The displayed java version (1.6.0_27) is different than the version declared in the PATH. There was an older version which I removed through the software center but the issue remains. Any help would be greatly appreciated.
That's because you already have openjdk installed (by default probably) on your system and the binaries provided by openjdk are already registered in $PATH. And that's where your problem is. Downloading the oracle jdk binaries and installing them in a custom location and exporting that location in JAVA_HOME, is not enough. You also need to add the path to the jdk binaries (javac, java, jar, etc) to the PATH environment variable.
A better way to do this is to install the oracle jdk via pre-packaged versions provided by ubuntu community: link. This would configure the path for you and set the necessary environment variables. And use alternatives to configure which would be the default jdk to use:
update-alternatives --config java
Or simply remove openjdk if you don't need it.

Android - Eclipse JRE not found

I have downloaded Android ADT Bundle and trying to create hello world android app.
I am following Setting up ADT Bundle which says just extract the zip file and launch the Eclipse.
I am getting following error
"A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: C:\adt\adt-bundle-windows-x86_64-20131030\eclipse\jre\bin\javaw.exe ..."
I know I can install JRE (with or without JDK), and set up javaw.exe dir in path ENV and the problem will go away.
But I think i ADT bundle should be self sufficient and should not require any additional download. Peculiar thing is that I cannot find jre dir inside eclipse.
Am I missing some additional steps? if yes, what steps?
Not sure this the best way to do but if copy paste the JRE folder inside the ecplise folder it works.
But I think i ADT bundle should be self sufficient and should not require any additional download. Peculiar thing is that I cannot find jre dir inside eclipse.
I don't think so eclipse folder will be having JRE folder you have to specify the path JDK path in ENV.
Check Windows -> Preferences -> Compiler and Windows -> Preferences -> Installed JREs.
If not configure them. If you have not installed JDK(It has JRE in it) then install it first.
To verify type java -version in your command line.
You should get output like
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
(Java 7 is latest but you can use any version that suits your requirement)
You should Install JDK and set class path. Because for compilation you need JDK not just JRE and JDK internally contain JRE.Therefore no need of installing JRE separately.

How do I set the default Java installation/runtime (Windows)?

I'm in the situation where I've installed the JDK, but I can't run applets in browsers (I may not have installed the JRE).
However, when I install the JRE, it clobbers my JDK as the default runtime. This breaks pretty much everything (Eclipse, Ant) - as they require a server JVM.
There's no JAVA_HOME environment variable these days - it just seems to use some registry magic (setting the system path is of no use either). Previously, I've just uninstalled the JRE after I've used it to restore the JDK. This time I want to fix it properly.
This also manifests itself with the jre autoupdater - once upon a time, I had a working setup with the JDK and JRE, but it updated and bust everything.
This is a bit of a pain on Windows. Here's what I do.
Install latest Sun JDK, e.g. 6u11, in path like c:\install\jdk\sun\6u11, then let the installer install public JRE in the default place (c:\program files\blah). This will setup your default JRE for the majority of things.
Install older JDKs as necessary, like 5u18 in c:\install\jdk\sun\5u18, but don't install the public JREs.
When in development, I have a little batch file that I use to setup a command prompt for each JDK version. Essentially just set JAVA_HOME=c:\jdk\sun\JDK_DESIRED and then set PATH=%JAVA_HOME%\bin;%PATH%. This will put the desired JDK first in the path and any secondary tools like Ant or Maven can use the JAVA_HOME variable.
The path is important because most public JRE installs put a linked executable at c:\WINDOWS\System32\java.exe, which usually overrides most other settings.
I have patched the behaviour of my eclipse startup shortcut in the properties dialogue
from
"E:\Program Files\eclipse\eclipse.exe"
to
"E:\Program Files\eclipse\eclipse.exe" -vm "E:\Program Files\Java\jdk1.6.0_30\bin"
as described in the Eclipse documentation
It is a patch only, as it depends on the shortcut to fix things...
The alternative is to set the parameter permanently in the eclipse initialisation file.
I just had that problem (Java 1.8 vs. Java 9 on Windows 7) and my findings are:
short version
default seems to be (because of Path entry)
c:\ProgramData\Oracle\Java\javapath\java -version
select the version you want (test, use tab completing in cmd, not sure what those numbers represent), I had 2 options, see longer version for details
c:\ProgramData\Oracle\Java\javapath_target_[tab]
remove junction/link and link to your version (the one ending with 181743567 in my case for Java 8)
rmdir javapath
mklink /D javapath javapath_target_181743567
longer version:
Reinstall Java 1.8 after Java 9 didn't work. The sequence of installations was jdk1.8.0_74, jdk-9.0.4 and attempt to make Java 8 default with jdk1.8.0_162...
After jdk1.8.0_162 installation I still have
java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
What I see in path is
Path=...;C:\ProgramData\Oracle\Java\javapath;...
So I checked what is that and I found it is a junction (link)
c:\ProgramData\Oracle\Java>dir
Volume in drive C is OSDisk
Volume Serial Number is DA2F-C2CC
Directory of c:\ProgramData\Oracle\Java
2018-02-07 17:06 <DIR> .
2018-02-07 17:06 <DIR> ..
2018-02-08 17:08 <DIR> .oracle_jre_usage
2017-08-22 11:04 <DIR> installcache
2018-02-08 17:08 <DIR> installcache_x64
2018-02-07 17:06 <JUNCTION> javapath [C:\ProgramData\Oracle\Java\javapath_target_185258831]
2018-02-07 17:06 <DIR> javapath_target_181743567
2018-02-07 17:06 <DIR> javapath_target_185258831
Those hashes doesn't ring a bell, but when I checked
c:\ProgramData\Oracle\Java\javapath_target_181743567>.\java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
c:\ProgramData\Oracle\Java\javapath_target_185258831>.\java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
so to make Java 8 default again I had to delete the link as described here
rmdir javapath
and recreate with Java I wanted
mklink /D javapath javapath_target_181743567
tested:
c:\ProgramData\Oracle\Java>java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
** update (Java 10) **
With Java 10 it is similar, only javapath is in c:\Program Files (x86)\Common Files\Oracle\Java\ which is strange as I installed 64-bit IMHO
.\java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
After many attempts, I found the junction approach more convenient. This is very similar on how this problem is solved in linux.
Basically it consists of having a link between c:\tools\java\default and the actual version of java you want to use as default in your system.
How to set it:
Download junction and make sure to put it in your PATH
environment variable
Set your environment this way:
- PATH pointing to ONLY to this jre c:\tools\java\default\bin
- JAVA_HOME pointing to `c:\tools\java\default
Store all your jre-s in one folder like (if you do that in your Program FIles folder you may encounter some
C:\tools\Java\JRE_1.6
C:\tools\Java\JRE_1.7
C:\tools\Java\JRE_1.8
Open a command prompt and cd to C:\tools\Java\
Execute junction default JRE_1.6
This will create a junction (which is more or less like a symbolic link in linux) between C:\tools\java\default and C:\tools\java\JRE_1.6
In this way you will always have your default java in c:\tools\java\default.
If you then need to change your default java to the 1.8 version you just need to execute
junction -d default
junction default JRE_1.8
Then you can have batch files to do that without command prompt like
set_jdk8.bat
set_jdk7.bat
As suggested from #СӏаџԁеМаятіи
EDIT: From windows vista, you can use mklink /J default JRE_1.8
I simply install all the versions of JDK I need and the latest installed becomes default, so I just reinstall the one I want to be default if necessary.
I have several JDK (1.4, 1.5, 1.6) installed in C:\Java with their JREs. Then I let Sun update the public JRE in C:\Program Files\Java.
Lately there is an improvement, installing in jre6. Previously, there was a different folder per new version (1.5.0_4, 1.5.0_5, etc.), which was taking lot of space
an alterable way to run an .jar app is create an .bat cmd for it.
for example, you have jre10 and jre8 installed on your pc,and jre10 is your default jre.
but your jar is specified to work with jre8,following cmd will work:
"C:\Program Files\Java\jre1.8.0_181\bin\java.exe" -jar JabRef-4.3.1.jar
Need to remove C:\Program Files (x86)\Common Files\Oracle\Java\javapath from environment and replace by JAVA_HOME which is works fine for me
Stacked by this issue and have resolved it in 2020, in Windows 10. I'm using Java 8 RE and 14.1 JDK and it worked well until Eclipse upgrade to version 2020-09. After that I can't run Eclipse because it needed to use Java 11 or newer and it found only 8 version. It was because of order of environment variables of "Path":
I suppose C:\Program Files (x86)\Common Files\Oracle\Java\javapath is path to link to installed JRE exe files (in my case Java 8) and the issue was resolved by move down this link after %JAVA_HOME%, what leads to Java 14.1/bin folder.
It seems that order of environment variables affects order of searched folders while executable file is requested.
Thanks for your comment or better explanation.

Categories

Resources