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.
Related
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!
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
It's not a duplicate. I would like to get current JRE version while program is executing.
To test result I've installed JDK 8.91 (without JRE 8.91 installation) and JRE 8.77. Also I've created JRE_HOME, JAVA_HOME variables, excluded Path variable with JDK folder.
My Tomcat uses JRE so I would like to get current JRE version before I will launch it. I found solution like:
System.getProperty("java.version")
After executing
System.out.println(System.getProperty("java.version"))
I get result 1.8.0_91 Instead of 1.8.0_77, which I wanted to get.
However, Oracle documentation gives the definition that this is JRE version.
Link:http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getProperty%28java.lang.String%29
How can I fix it?
When you run a Java program, it always runs on a JRE (Java Runtime Environment). You cannot run a program on the JDK directly.
When you install Oracle's JDK, a JRE is included, you can find it in the jre directory in the JDK installation directory.
When you install Oracle's JDK, you get an option to install a "public JRE". This is a JRE that is installed separately from the JDK itself, and is used by browser plug-ins. You need this only if you want to be able to run Java applets in your browser.
I am new to Java and have some basic problem. Would appreciate your help guys.
I try to run a HelloWorld program but having an error:
"Error: Could not find or load main class HelloWorld".
I noticed that Eclipse saves the project in parallel virtual store directory and not the one I mentioned.
When I manually move the project to Eclipse_Workspace directory it works just fine. What should I do for Eclipse to save the files correctly?!
If needed:
I downloaded JDK 1.8.0_51 for Win 32 and Eclipse IDE for Java developers (Luna Service Release 1 (4.4.1)). Win7 32 Ultimate.
I added a Path value in System Variables -
C:\Program Files\Java\jdk1.8.0_51\bin
Default Resource Path in Eclipse is:
C:\Program Files\Java\Eclipse_Workspace
Thanks
VladBio,
Make sure the following environment variables set correctly:
JAVA_HOME = jdk root folder (C:\Program Files\Java\jdk1.8.0_51)
Path = jdk bin folder (C:\Program Files\Java\jdk1.8.0_51\bin)
To test this go into your cmd (Start -> run -> cmd) and type:
java -version
C:>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
If you see the correct version then the issue is in Eclipse.
In Eclipse you can check your JDK settings in Windows -> Preferences -> Installed JREs. Your correct JDK should be listed there.
On Eclipse you can also have project specific java version.
Right click on your project -> properties. On Library tab you should see something like JRE System Library [jdk1.8.0_45]
Check here for a more detailed answer of what could be going wrong.
I Hope this helps.
Thanks a lot.
I suppose I figured this out.
It was a problem in eclipse - it couldnt automatically make a changes in java directory because any change there is allowed only with admin approval.
I changed the path in eclipse to a folder on my desktop. It solved out the problem.
BTW I tried what you said and the output in cmd was identical to yours.
Thanks again
I am new in learning java programming! I want to make a .jar in a maven project. After running this command mvn clean install, I am getting the following error message:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile(default-compile) on project wps-demo: Compilation failure
Unable to locate the Javac Compiler in:C:\Program Files\Java\jre7..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable
what can I do for clean this error!
It looks like you have only a JRE (Java Runtime Environment) installed, and not a JDK (Java Development Kit), as this error message says:
Please ensure you are using JDK 1.4 or above and not a JRE(the com.sun.tools.javac.Main class is required)
Download and install the JDK (not JRE) from Oracle's website.
The JRE allows you to run Java programs, but does not include the tools that you need to develop Java software, such as the Java compiler. The JDK does include those tools.
If you already have a JDK installed, then make sure that the JAVA_HOME environment variable refers to the directory where you have the JDK installed, and not to a directory with a JRE.
As your error says you have wrong value in JAVA_HOME variable in system settings... should be something like C:\Program Files\Java\jre6
You can find how to set it HERE for example.
You need to set the environment variable that specifies the location of your java development kit so that windows can find the Java libraries
Put java home path in a JAVA_HOME variable that you can create in the advanced tab of MyComputer properties.
The Java home path would look something like this
C:\Program Files\Java\jdk1.5
Hope this helps
You may also want to have a look at the following article from Maven http://maven.apache.org/guides/mini/guide-building-jdk14-on-jdk15.html
It states that from Maven 2.2.0, Java JDK 1.5 is needed to allow Maven to build the Java project. The article also goes on to show how some of these adjustments can be made so that JDK 1.5 or later can be used in the build process.