What is this runtime error when I run my project? - eclipse

Using Eclipse Photon, importing a project created elsewhere. There are no errors in the edit window when I load the source code.
I get this error when I click Run:
Exception in thread "main" java.lang.UnsupportedClassVersionError: myPackage/Bookstore has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I reconfigured the build path to use my Workspace default JRE, which is 1.8.0_181, and I deleted the bin folder but the error persists.

I was selecting the Workspace Default JRE : that didn't fix the problem. I tried selecting the Execution Environment JRE and that worked. Here are the steps. It's Eclipse Photon but that should be similar to other recent versions. Here's a video that illustrates the steps: https://youtu.be/IE2B2e90kCs
Open Eclipse, verify your project is loaded in the Project Explorer
Right-click on the project in Project Explorer
Select Build Path
Select Configure Build Path
Click on Libraries Tab
If there is a system library, remove it
Click on the Add Library Button
Select JRE System Library
Click Next
Under System Library: Select "Execution Environment"
Click Finish
Click Apply and Close

Related

pom.properties (The system cannot find the path specified)

I am facing below issues while executing a project in Eclipse:
Publishing failed with multiple errors
File not found: D:\Programs\j2ee\OnlineLibrary\target\m2e-wtp\web-resources\META-INF\maven\OnlineLibrary\OnlineLibrary\pom.properties.
D:\Programs\j2ee\OnlineLibrary\target\m2e-wtp\web-resources\META-INF\maven\OnlineLibrary\OnlineLibrary\pom.properties (The system cannot find the path specified)
File not found: D:\Programs\j2ee\OnlineLibrary\target\m2e-wtp\web-resources\META-INF\maven\OnlineLibrary\OnlineLibrary\pom.xml.
D:\Programs\j2ee\OnlineLibrary\target\m2e-wtp\web-resources\META-INF\maven\OnlineLibrary\OnlineLibrary\pom.xml (The system cannot find the path specified)
System Configuration:
OS: Windows 8.1 (64-bit)
Tomcat: 8.0.30 (64-bit)
Java: jdk 1.8.0_45 (64-bit)
Maven version: 3.3.9 on C:/
Eclipse: Luna 4.4.2
Steps followed:
Configure maven in eclipse
Updated the settings.xml file with custom repositories path placed on C:\apache-maven-3.3.9\conf
In Eclipse:
Click Project-->Preferences-->Maven. Selected the artifacts download options
Click Maven-->Installations. Added the maven installation (C:\apache-maven-3.3.9) and set it as default
Click Maven-->Templates. Below mention Templates are in "Off" mode
"m2e profile","m2e-wtp activation,"m2e-wtp JAX-RS activation","m2e-wtp JPA activation","m2e-wtp JSF activation",
"m2e-wtp's specific context root property".
Click Maven-->User Settings. Global Setting, Local Settings points to C:\apache-maven-3.3.9\conf\settings.xml
Local Repository points to custom repositories path as below:
D:\Programs\Maven\Maven_Repositories
Created a new dynamic web project (project name: OnlineLibrary). Renamed the src folder as per Maven project structure.
Right clicked on project -->Configure-->Convert to Maven Project. Right click on the project-->Maven. Selected Resolve
dependency from workspace projects.
Added required dependencies to the project.
Project Build successful as per Maven clean, build, install process.
But when I try to execute/Run the project on server error is displayed:
This does not explain the problem but i resolved same problem with Maven->Update Project(s)
Go to "Servers" tab and start server first. Make sure this is same server which your project is using. If server is not already added then add new server.
Now run you project, it will ask for server to "Continue" to "Restart Server". Choose "Continue" and it should run fine. It worked for me.

Eclipse error - Can't find Maven installation

I have been using maven in eclipse (with m2e) just fine, until recently when I renamed one of the folders on my hard drive where maven is installed.
The folder was renamed from Computer local to ComputerLocal
After renaming the folder I received the following error in eclipse when I attempted to do a maven build:
Can't find Maven installation C:\Computer local\apache-maven-3.0.4
Which of course makes perfect sense.
The problem is that when I re-named the folder on the installation directory path back to it's original name I kept receiving the same error as before:
Can't find Maven installation C:\Computer local\apache-maven-3.0.4
When I copy-past the directory path from the error into a explorer window it finds the directory just fine.
So what I'd really like to know is where can I find the configuration in eclipse where I can see path to the maven installation that is being used? Perhaps from there I can re-set it or re-configure it?
"Can't find Maven installation EMBEDDED" means it is that you are facing the issue with your eclipse version.
You just need to restart the and Check your eclipse settings
Windows-->Preferences-->Maven-->Installations
You can find the Embedded version of Maven.
This can be done by selecting your project and setting up with few goals in "Runtime Configurations" and few settings for Java and Environemnt Variables.
Right clicking on your parent POM file.
Select "Run As"-->"Maven Build"
In the Run Configurations window,
a) Enter project name, b) select your parent-project, c) provide some goals eg., clean install
Choose your External Maven from the dropdown. If you can not find your External Maven (other than embedded maven), Clicking on Configure and click on Add button and add your maven home location folder.
Setup your environmental variables with variable M2_HOME to your maven home location folder and also set PATH variable to %M2_HOME%\bin
In Eclipse, goto Window-> Preference -> Java -> Installed JREs -> Edit and pass VM Arguments as -Dmaven.multiModuleProjectDirectory=M2_HOME for windows and -Dmaven.multiModuleProjectDirectory=$M2_HOME for Linux and Mac OS X.
For versions Maven 3.x, and above, the variable can also be named as $MAVEN_HOME.
-Dmaven.multiModuleProjectDirectory=MAVEN_HOME for Windows
-Dmaven.multiModuleProjectDirectory=$MAVEN_HOME for Linux and Mac OS X
However, It is better to use M2_HOME as it supports for both Maven 2 and 3.

Tools jar does not exist Eclipse JAVA

The archive: C:/Java/jdk1.6.0_26-32/lib/tools.jar which is referenced by the classpath, does not exist.
This is the error I have when run Tomcat. There was no problem cleaning or publishing - only when i start the Tomcat server.
Now, I checked my folders and there is a tools.jar in file path C:\Java\jdk1.6.0_34\lib
What am i missing?
using jre6 and have jdk1.6.0_34 installed
I found this question trying to build my project using Ant in Eclipse, and I would get the same error message as above. The suggestions in #Parth's and other answers to edit the Installed JREs is the first step. What I also needed to run Ant successfully was
Right click on build.xml, select "Run As", select "Ant Build..." (note the ...)
Click on the JRE tab
Change the Runtime JRE to the same thing that you updated in the first stage, and press Apply. (That is, the runtime JRE as you specified by "Preferences" -> "Java" -> "Installed JREs", as in #Parth's answer.)
Otherwise it seems that Ant will still try to build with the old JRE that doesn't have tools.jar. Hope this helps someone.
Right click on your eclipse project, In Preferences go to Java > Installed JREs, select your JDK and click on Edit. In the new Dialog you can add external jars like tools.jar to your execution environment.
I found the solution to resolve this.
Go to Run Configurations > classpath and under User Enteries you will have tools.jar and its path would be pointing to the old folder. Remove that and click on "Add External Jars" to add the tools.jar from the new path. And that is it.
This worked for me on Eclipse:
Windows -> Preferences -> Select Java -> Select Installed JREs -> Add
-> Add your JDK -> Establish it as default -> Apply -> OK.
After this, I've to establish project related settings too:
Right click on your Project Name (in Project explorer ) -> Properties ->
Java Build Path -> Click on JRE System Libraries -> Edit ->
Select Workspace Default JRE (jdk included above)
Check your "run configurations" (Eclipse Menu Run -> Run Configurations ....) also, since therein the classpath may be wrong or has gotten obsolete.
Tomcat needs a full JDK/SDK to run but under C:/Java/jdk1.6.0_26-32/, you only have a JRE installed.
Cleaning and deploying is done by Eclipse, no Tomcat code is involved so this works.
You need to configure your environment so that Tomcat uses C:\Java\jdk1.6.0_34 as Java VM. Check the values of JAVA_HOME and the content of setenv.bat
Right click on project->Properties->Compiler->Configure workspace settings->go to configure->installed jre->give jdk path
In my case with using ANT build I had to change the setting
Add tools.jar in the below location.
Windows --> Preferences --> Ant --> Runtime --> Global Entries.
In my case the Tomcat server in Eclipse has been created under older JDK (just a few builds). My solution was to remove the sever and add it again (now using current JDK).
I had the same problem (I can reproduce it) and my solution sounds like the integration in Eclipse is really screwed up but I actually fixed it by starting Eclipse with the same JDK version.
Add/edit the following in your eclipse.ini (which is in the Eclipse directory):
-vm
path/to/jdk/bin
Where path/to/jdk/bin is the path to the JDK bin directory of the version you are using for ant/tomcat.
Note that tools.jar is NOT included in a JRE distribution.
If you are running Ant build file and getting this error in eclipse, then your eclipse is configured to use two differently named JRE's. i.e. One from the jre folder and another jre from inside the jdk's folder. Adding tools.jar may be a workaround but I used the JRE inside the JDK's folder(C:\Program Files\Java\jdk1.8.0_121). Inorder to change this,
Check in Installed JRE section which JRE is cheked(I had jdk1.8.0_121 checked and jre1.8.0_121 left unchecked).
Update your eclipse classpath by navigating to Window > Preferences > Java > Installed JRE > Execution Environments.
Now select the JavaSE-1.x on the left side and select the compatible JRE[perfect match]. Select the same JRE(jdk1.8.0_121) you had it checked above and click Ok. Optionally you can delete the JRE(jre1.8.0_121) which is unused to avoid confusion if it is not used in any other projects.
Now your project will build and you can run the Ant build files. Check the image below.
Try to add the tools.jar as an external JAR.
For eclipse,
Right click the project name and select Properties
Go to Java "Build Path"
Select tab "Libraries"
Click "Add External JARs"
Select the relevant .jar file from the file selection
I am not sure it applies to all situations, but if you right click Ant script and there is an item "External tools configuration" under "Run as" menu, select it, and go to JRE tab. As far as I can say, it may be configured independently from your project and point to the JRE, not JDK, in which case there would be missing tools.jar
I remove server (Tomcat 6.0) from window -> preferences -> server -> Runtime environment.
And add again. Then, I add my project to server again. The problem is destroyed.
If You are getting this error while running the ANT build then follow the below steps.
In the Eclipse go-to window-> preferences-> ANT-> RUNTIME
then select classpath tab then select Global Entries and add tools.jar as an external jar.
Run the ANT build.

How to import JavaFX 2 project created from netbeans 7.2 in Eclipse?

I want to use Eclipse to develop JavaFX. I am trying to import a JavaFX 2 application created in Netbeans 7.2 into Eclipse. But Javafx 2 uses its own Ant build syntax. So when I try to import this Ant project into Eclipse I get the following error:
Specified build file does not contain a javac task
How do I solve this error? I know there are JavaFX plugins for Eclipse, but I haven't been able to find any that solves my problem. Or do I need to try something else?
Open http://efxclipse.org/install.html, scroll down to "In Eclipse 4.2 for the adventurous".
After you have configured properly by setting the path for JavaFX SDK from Window->Preferences, create a new JavaFX project (File->New->Other->JavaFX->JavaFX Project)
Right click on your projet->Import->File System->Select the top level of your NetBeans created project folder-> Select src folder,build.xml, manifest.mf and any other FXML files you wish to import.
For a distributable standalone executable JAR, refer to http://www.efxclipse.org/tut2.html. If you face any problem in Step 11- Click on the "ant build.xml and run" Link in the Build section of the editor, then goto Window->Preferences->Ant->Runtime->Global Entries->Add External JAR->(Browse to your JDK lib folder) Add tools.jar.
If your Build still fails and shows this error ->
BUILD FAILED C:\Workspace\eclipseFx\AppOne\build\build.xml:82:
Problem: failed to create task or type
javafx:com.sun.javafx.tools.ant:resources
It means ${java.home} is pointing to the JRE and can access jfxrt.jar but fails to access ant-javafx.jar. Find the absolute path for ant-javafx.jar in your JDK and edit that line in build.xml and it should build fine. This error has been fixed in the Nightly Build.
P.S. - You can also create JavaFX RCP applications now. Eclipse 4 Applications can use JavaFX as the rendering technology instead of SWT.

Red exclamation mark in Eclipse with mercurial

I have imported a project with Mercurial (hg clone ...).
When opening it with Eclipse, a red exclamation mark appears by the project's name in the Project Explorer, and it cannot be built. Silly messages like "import java.util cannot be resolved" appear, and errors in files are not marked in the Package Explorer.
How can I resolve this?
Check the problem view. By exclamation it is usually means a problem with build path
Check the Build Path of the project by right clicking the project and select Build Path -> Configure Build Path.
One problem I often encountered is different people using different Java SDK and so when the exact SDK is not available in your machine, you need to change to your Java SDK (via JRE System Library -> Alternate JRE). A better way to avoid this problem is to always select the JRE System Library from Workspace default JRE or Execution Environment.
I solved the problem by adding the external .jar file in to my project.
RightClick on the project -> Properties -> Java Build path -> libraries tab -> Add jar
Select your jar file and added it
Thats it the red ! mark gone.
Some times it happens that you have added a jar file earlier but currently not using it. Then after some time you delete the jar file from your system. But since you are not using the library file, so you will not get any error.But then you will see the red exclamation mark for the project. So all you need is to remove the added jar from the Build Path.
Done.....
The Java Runtime Library was defined wrong for the pulled project.
It had to be reset under Project | Properties | Java Build Path | Libraries.
It means there is a problem with the build path in your project. If it is an android project then it mostly means the target value specified in project.properties file cannot be found. This can also be caused because of other kinds of built problems. But it is shown mostly for built problems only. See here for more details. It is about built error decorater seen in eclipse.
An extract from that page:
Build path problems are sometimes easy to miss among other problems in a project. The Package Explorer and Project Explorer views now show a new decorator on Java projects and working sets that contain build path errors:
The concrete errors can be seen in the Problems view, and if you open the view menu and select Group By > Java Problem Type, they all show up in the Build Path category:
I figured out each time i am trying to import a library into my android project, i have a red exclamation mark with both ActionBarSherlock and Facebook libraries
This is how i solved it:
After adding the library into your project "project properties->Android->Librairy->add"
If you are using Eclipse, all you have to do is to clean your project and build all your workspace:
"project -> clean... -> "clean selected project" -> build the entire workspace
For me, the problem was a simple one - the reference project was compiled in 1.5 and my project 1.6. Matching the two solved the issue.
Right-hand-click on the project, select properties, select java compiler.
This is how I solved this problem:- Right-Click to project->properties->Java Build Path->Libraries(tab)->Remove the Jar which is already present there with a Path given along.