Accepted the automatic Java update and now can't open Eclipse, - java

I'm very new to Java and computing in general. Currently taking an intro to programming course revolving around Java.
I got a notification earlier about a Java update when I wasn't using it and accepted it without much thought. I just now tried to open Eclipse to start doing some homework and when I did, all I got was the following message:
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:/Program Files/Java/jre1.8.0_144/bin
I have no idea where to go from here. I can't get in touch with my web developer friend helped me set up Java on my computer originally, and my instructor isn't responding to emails. I've tried to fix things like this myself in the past and have only compounded the problem, so I'm reluctant to try anything I'm not certain about, which is to say I'm reluctant to try anything at all. Any help is appreciated.

First, try to find where your jdk locates. If you don't remember where you have installed it, try to search for jdk or jre folder in C:/Programm Files. Then go to Window -> Preferences -> Java -> Installed JRE's tab in Eclipse and set path to your jdk or jre.

Got it figured out from an old question- just had to change the text to the updated JRE in the Eclipse initializer. Thank you for your help!

Related

How can I set the path to my Java decompiler in VSCode

I am relatively new to stack overflow, VSCode, and programming. I am using a Mac. I downloaded VSCode for use with Python around two months ago. I can not run my code in VSCode but I enjoyed working in VSCode so I would write in it and run my code outside of it. Now I have the same issue with Java. I can not "solve," this in the same way because I do not know how I can run my Java code outside of an IDE.
I first read the instructions for setting up VSCode for Java on VSCodes website. I followed the instructions but when I tried to run a, "Hello world," program it said I did not have a debugger. I re-installed Redhat's Java support, closed and re-opened VSCode, and tried to run it again. This time it said java.jdt.Is.home is pointing to a missing or inaccessible folder. I looked this up found one description of this issue from 2018. I had a hard time understanding what it was asking me to do but at my best interpretation I wrote "which java," in Terminal and copy pasted what it returned (usr/bin/java) into settings.json after "java.home: ". This gave me an error stating that it is outdated and I should change it to, "java.jdt.Is.home: " so I did. I also tried adding "local/" between "usr/" and "bin" as it appeared in my path to my Python3 interpreter. All of these gave me the same error when I tried to run a hello world program.What can I do to solve my issue with Java in VSCode?
which java can not get the right java home.
You need to take /usr/libexec/java_home or /usr/libexec/java_home -V.
Java home on MacOs looks like: /Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
But You need not set the "java.jdt.ls.java.home" at all. Because the JRE has been embedded in the Language Support for Java(TM) by Red Hat extension.
Only the universal version without embedded JRE can specify the java.jdt.ls.java.home manually. Otherwise, it will search JDK_HOME JAVA_HOME current system path.
You can refer to the official dosc.
So, have you installed the related extensions? You can install Extension Pack for Java, which contains the extensions you need.
I am a little confused about why you can not run the python or java codes, it's very rare. After you installed the related extensions(Python Extension Pack) , just right-click in the editor, you can select the Run Java Debug Java Run Python File in Terminal and so on. Or you can click the button on the top-right.

Eclipse won't load: failed to find a main class

I am trying to download Eclipse onto my flash drive so that it can support itself if I try to use Eclipse on a computer that does not have a JDK/JRE installed and/or I do not have the permissions to install one.
I am able to download it onto the flash drive and run it fine, but the problem arises when I try to make it self-sufficient by downloading a JDK for Eclipse to use on the drive. I have tried many different solutions (yes, I am aware of the abundance of "why is eclipse telling me it cant find main class" questions), but none of them apply to me. I followed this tutorial in my endeavors, but when I run the batch file it comes up with the standard Failed to find a Main Class in "F:\eclipse\\plugins/org.eclipse.equinox.launcher_1.5.200.v20180922-1751.jar.
I know the \\ looks a bit out of place, but I know that's not the problem since I've tried editing the eclipse.ini file to fix the path but it gives the same error (just with F:\eclipse\plugins\org.[...].jar instead)
I'd really appreciate any help anyone could give. Thanks!
Eclipse has required Java 8 or newer since the Neon release, in 2016. Update your version of Java.

How to work with NetBeans IDE 8.2 on Windows 7 64-bit with JDK

I've been having trouble using NetBeans IDE 8.2 with JDK on Windows 7 64-bit. NetBeans can compile code, but doesn't run it. I've downloaded all of the necessary files and programs and even consulted with a computer programming teacher, but I haven't been able to work around this issue. The URL displays an image that shows what I get back after attempting to run a code.
https://i.stack.imgur.com/RsEvx.png
I appreciate any help I can get.
Thanks,
--Sam
JavaApplication1.java is still set as your main class.
To change your main class, go into Project Properties -> Run and change "Main Class" to TestClass.java.
Essentially, the compiler is still running whatever main function is found in JavaApplication1.java.
#notyou Also mentioned how you can right click a file and run it directly, instead of changing the project settings. I used to use this but it slipped me! This is super useful.
I'm pretty sure this question has some answers for you.

Visual Studio Code - Java - Import Errors and More

Just starting working on an existing project at work and wanted to use Visual Studio Code as my IDE (I have used it for a recent Rails project and loved it, so wanted to try with Java).
However, whenever I try to open one of the projects I receive a ton of different errors including:
When importing java.io, java.util, or anything similar, the error:
"The import of java.io (or java.util) cannot be resolved"
Existing classes have an error:
"The implicit super constructor is undefined for default constructor. Must define explicit constructor"
Other random "cannot resolve to a type" errors.
All of these seem to stem from some sort of setting error I have with VS Code but can seem to find what it is. I have already uninstalled and reinstalled the RedHat plug-in that enables the Java language for VS Code.
I have tried setting the java_home setting in the extension to the direct location of the install but that didn't work. Tried uninstalling and reinstalling java and that also didn't work.
My operating specs are as follows:
OS: macOS Sierra
VS Code version 1.15.1
JDK version 1.8.0.144
Any idea on what may be causing this? Do you think it may be an error in how I have VS Code set up or if it's an error (or rather incompatibility) with how the existing project is set up?
I ran into a similar issue. The solution was to remove everything from VS Code's workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.
I found this solution here: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory
Update: This can now be done from within VS Code as of Language Support for Java(TM) by Red Hat Version 0.33.0. Open the command palette and type "java clean" (see official description in link).
As already mentioned previously, you require to clean the project, but that is a bit difficult thing because every folder is a Guid, and you do not know which one to clear, thus requiring you to delete everything. Starting with 0.33.0 version of the plugin you can automatically do that from within the IDE as well, use CTRL + Shift + P and type, java clean, and IDE will show you the suggestion tip for, Java: Clean the Java language server workspace. Upon selection, agree and restart the IDE. It will clean the language server workspace for you.
Another approach can be, the Maven tools within the IDE. If you have this plugin installed, you can use the side bar and utilize the Maven project helper options to perform actions like, clean, install, and package etc. For example, here is the project I am having and the options this shows,
That can be used, graphically, to manage your Maven-based projects. Also, this would work with the Java Extension Pack, not sure yet as to how it would behave with other extensions.
For me: CMD + Shift + P
Then type "Java: Clean Java language Server Workspace"
Note: This will reload/restart vscode as well.
Update:
This appears to not fix it anymore for me. In my case I am using a gradle project, and needed to set the rootProject.name in the settings.gradle to be the same as the folder name that the project is in.
I faced this issue after creating a whole Java project in one computer and then trying to run it on another computer.
After doing everything said in the other answers, what really made VS Code compile was to open each single project java file in VS Code and save it (a simple Ctrl + S). Maybe there is a simpler way of doing it, but that is what worked for me and I hope this helps anyone stuck in this issue.
Press ctrl+shift+p
then search 'java clean' and click 'java: clean java language server workspace' then click restart IDE.
I found another simple trick at least to get rid of "cannot be resolved to a type" errors which were coming from older workspaces and wrong project files I guess?. I just ran an empty main(), with the body commented out, while still keeping my local package / import commands at the start - no errors. After commenting in again, the project compiled without errors. Perhaps this refreshing effect might also help in this context?
I had to clean this folder to get it working on Windows
%APPDATA%\code\Local Storage

Java Runtime Environment HKEY_LOCAL_MACHINE Error

I was trying to get rid of older versions of Java (since I still had 1.6 and I also had 1.7) on my Windows XP machine. Well uninstalling 1.6 I got an error about Java Runtime Environment. When I try and start up Java Control Panel it gives me this error:
The system cannot find the registry key specified:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.7.0_05
I've tried to reinstall Java but that does nothing. And I can't fully remove Java because whenever I try it gives me an error saying there was an error in the installation. To be specific:
Fatal error during installation.
Any idea how I can fix this issue? It keeps me from doing a lot which is frustrating.
Author's note: This answer was written to address installations of Java, major versions 6 and 7. It may or may not work with versions of java that are newer or older, but it probably won't hurt to try. If you follow these instructions for a major version not listed, please comment whether you were successful or not.
Read all of the directions twice. This solution details a manual uninstall of java by modifying the windows registry. If you do not follow the directions, you can cause permanent damage to your windows installation and will need serious firepower to get it working correctly again. If you do not understand the risks, ask someone for help.
If you have any registry cleaners, get rid of them. This is probably their fault. I've never met one I liked and wouldn't let one touch my registry with a 10 foot read only pole.
If you're using a laptop, connect to a charger. If you have children, make them walk the dog. Find a quiet secluded place and hole yourself up in it with zero distractions for about 15 minutes.
Make a backup of the registry key "\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft", save it somewhere safe.
Delete exactly the following and only exactly the following registry key and all of its subkeys: "\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft". After you are done with this step, java is dead. Do not try to run any java programs at this stage, it almost certainly won't work.
Open "C:\Program Files" (and, if you're on a 64 bit machine, "C:\Program Files (x86)"). If you see folders called Java, rename them to "Java_". If you installed java to a nonstandard location, navigate to it and add an underscore to its name.
Download and install the latest version. The installation should complete with no issues. It should also overwrite any leftover chunks of the old installation that are left.
(optional) Uninstall java again. The uninstallation should go smoothly and it should properly dispose of any leftover resources installed by the broken installation. Reinstall when the uninstall is complete. Since you are installing the same version you just removed, this probably isn't necessary.
Final note: I have performed this surgery many times on other people's computers using teamviewer, and it has never gone wrong. In the social circles where I hang out, we call it a javaectomy. For reference, I hang out on IRC and help people with issues with minecraft. We think we have seen every possible java issue. This one is fairly common and caused by some combination of many concurrent java versions, registry cleaners, and interrupted or failed updates. Once you are done and have verified that the reinstallation has gone smoothly and without issues, you can remove your saved registry keys and delete the renamed java folders from "program files" and "program files (x86)" (remember to delete only the ones with an appended underscore, the one called Java was added by the reinstall and should be left as is.
Disaster recovery: In the unlikely event that something goes wrong, restore the renamed java folders and patch the registry keys with your backup to revert to the original (partially broken) state.
I must congratulate Wug for his/her contribution in removing old Java residues. I tried every Uninstaller available (free) to no avail. Except for a Caveat, everything Wug suggested works. The only Caveat is that after #6 (renaming Java Folder in Program Files), you must use the Windows Uninstaller. Why? Because if you try to install the downloaded Java, it will warn you that you already have Java installed. Run the uninstaller from the Add or Remove Programs (Control Panel). It will give you an error that it couldn't find the uninstaller and then it will remove the Java reference from the Add/Remove Programs. Then do installation of the downloaded Java file and you are free of the old Java references.
GREAT JOB, WUG!!
I faced this issue while updating Java on my machine to 1.8. I had opted for uninstall of existing version while the installation and it did something to the registry keys.This fix worked to me .
Uninstall all versions of JDK and JRE from your machine.
Restart it.
Install 1.7 JDK.
Then install whatever JDK you want.

Categories