Tools jar does not exist Eclipse JAVA - eclipse

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.

Related

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.

adding jfxrt.jar to standard Eclipse build path

How can I convince eclipse to include jfxrt.jar into its standard build path by default in order to avoid editing it manually every time I change the JVM?
thanks!
The more convenient way is :
Go to > Window > Preferences > Installed JREs > Edit your jdk >1.7u7 location
Then click on "Add external Jar" and choose the jfxrt.jar provided by the Jdk.
All JavaFX classes will be available for all your projects , just by adding this custom Jdk
The pitfall is that you can't use Execution Environment because the jfxrt.jar has not been added into Eclipse jars definition of a Jdk.
You can add jfxrt.jar from Project -> Properties -> Java Build Path -> Libraries -> Add External Jars
Unfortunately, you need to do it for each project.

Using Eclipse, how can i tell what version of ANT is being used?

Same as original question, using Eclipse, how can i tell what version of ANT it is configured to use?
In Eclipse Helios:
Open the Preferences dialog (Window -> Preferences)
Navigate to the Ant -> Runtime page
Expand the Ant Home Entries node on the Classpath tab
This shows the path used for Ant classpath, which also reveals ANT_HOME for Eclipse.
So by default in Helios you will have something like:
<ECLIPSE_ROOT>/plugins/org.apache.ant_1.7.1.v20100518-1145\lib\ant.jar
etc
On this same page, you can also change ANT_HOME to use a different version of Ant you have installed on your PC.
Create a build file and echo $ant.version
On Helios
create an empty build.xml
ctrl+space in the empty file and select the default build file template with 2 targets
in the target called "default" add <echo>${ant.version}</echo>
save the file
right click on the build.xml in the navigator
select run as ant build
In Eclipse Helios (version 3.6.2) the version of the various plug-in modules such as ANT can be determined in the following manner.
Select the Help -> "About Eclipse SDK" menu option
Click on the "Installation Details" button
Click on the "Plug-ins" Tab
The "Plug-in Name" column is where ANT can be found the version is in the next column.
There will probably be multiple references to ANT in the "Plug-in Name" column including
Ant Build Tool Core
Ant Launching support
Ant UI
Apache Ant
I believe the "Apache Ant" is the most relevant entry and the others deal with how ant integrates with eclipse.

How do i configure eclipse to make use of different version of JDK

I have three project running on eclipse i want to use JDK 1.4 for two project and JDK 1.6 for third project how do i do that?
You need:
first to declare the different JRE in your Eclipse: See "Eclipse - no Java (JRE) / (JDK) … no virtual machine…"
then to add the right JRE in your project settings (see this blog post for instance)
The default JRE is shown with a check mark and is used by new eclipse projects unless the project specifically overrides the value.
So the next step is to check which JRE the current project is using.
Right click the project and choose "properties".
Select "Java Build Path" and then click the tab labeled "Libraries". You should see an entry like "JRE System Library [version]".
To change the JRE version,
highlight the entry and click "Remove".
Then click "Add Library...". Choose "JRE System Library".
If you choose "Workspace Default", the project will use the JRe defined under "Windows -> Properties" as explained above.
You may also specify an alternate JRE located somewhere on your file system, or choose an embedded execution environment provided by Eclipse.
you can configure VM in eclipse.ini file.

How can I add my application to Tomcat in Eclipse?

I have a web app built with Maven.
Most of the time, I built the application using Intellij IDEA, but now I want to import the application in Eclipse to see something in this IDE.
After mvn eclipse:eclipse, I add in Eclipse the app, but when I try to add the app to the server (tomcat), I receive:
There are no resources that can be added or removed from the server
Solutions?
You need the project to have a Eclipse Dynamic Web Module facet. You can try doing this via the project properties dialog and looking at project facets, then clicking the appropriate check box. This may not be available however, so you may need to do the next thing.
Create a backup of your project and follow the directions at dzone.com. This'll allow you to modify the project facets via your eclipse .project file.
Keep in mind, once you add those facets, you cannot change them back via Eclipse. Definitely make sure you have a backup before starting.
This step worked for me:
Right-Click on the Project Name, then
Maven-->Update Project..
Click OK
After doing this I was able to see my project in Add/Remove Programs.
As mentioned somewhere else adding Eclipse WTP didn't do any good, however I performed the above step after I had already added Eclipse WTP, so I am guessing that may not be needed.
This was done for Eclipse Juno.
Hope this helps someone.
Edited: You can follow this link as above mentioned I think might have needed WTP and that add a lot of other things into the workspace.
http://blog.teamextension.com/maven-as-eclipse-dynamic-web-module-556
Check whether Maven Integration for Eclipse WTP is installed. If not, install it from Eclipse Marketplace
After installation restart Eclipse
Right click your project and Maven--> update project configuration
Delete tomcat and re create tomcat (clean tomcat,add your project,publish and enjoy)
I've got Tomcat 6, Java 1.6, and was trying to get it to work in Eclipse Juno Service Release 1's "internal server" (whatever that's called.) Here's what I did that worked for me:
(Found these instructions at http://www.mkyong.com/eclipse/eclipse-ide-tomcat-version-6-0-only-supports-j2ee-1-2-1-3-1-4-and-java-ee-5-web-modules/)
I should point out that I followed ClutchDude's instructions to make my project a Dynamic Web Module facet. It didn't work on its own for me, but maybe it was part of making it work in the end.
Using Eclipse (or other text editor), open the file
.settings/org.eclipse.wst.common.project.facet.core.xml
Find the line that reads
<installed facet="jst.web" version="3.0"/>
3.0 is for Tomcat 7.x (so says mkyong.) Change it to 2.5 (or 2.4).
I restarted Eclipse and it worked for my project.
The reason why this is happening is because eclipse by default looks for the deployment descriptor in the folder {project.home}/Webcontent/WEB-INF/web.xml where as the Maven puts them in src/main/webapp/WEB-INF/web.xml.
So when you are trying to add your project onto the server eclipse cannot find a deployment descriptor and hence you get the annoying message.
This can be solved by adding the following entries in .settings/org.eclipse.wst.common which can be found in
Project home folder in your workspace if it is a new maven project.
The folder where you already imported from if you are using Import -> Maven projects.
Make the following changes in to the org.eclipse.wst.common
wb-resource deploy-path="/" source-path="/src/main/webapp"/. Add this entry.
Edit --> property name="java-output-path"
Please check the following link from more details. http://java.dzone.com/articles/webapps-eclipse-and-maven.
The comments section has an excellent example with a working project.
This issue was fixed for me my installing additional eclipse modules. in particular, the ones related to m2e-wtp. just do a search for m2e in the plugins search listing for your version of eclipse
If you face an error like "There are no resources that can be added or removed from the server",
then
1) Go to the META_INF of your websvcsEAR and go to the application.xml.
2) Goto modules-> clickDetails and add the module that is existing. i.e., some EAR which your project demands.
3) Click ok
4) Now go to your server -> right click -> add and remove -> add your EAR.
Maybe you don't need add your application to the server's configuration. I think that you must use m2e eclipse plugin in order to launch the app.
For example, in your eclipse you will see a contextual menu called "Run as" if you right-click on your pom file. You can clicking on "Maven build" and Maven will download all the information needed to start tomcat.
I hope this helps you.
I used
mvn eclipse:eclipse -Dwtpversion=2.0
in command line in the folder where I had my pom.xml. Then I refreshed the project in eclipse IDE. After that I was able to add my project.
I was able to resolve this by removing my EAR project from my Eclipse workspace, then re-importing it.
Well, with a Spring and maven project, i got it that way:
Eclipse Version: 2019-06 (4.12.0)
Java 1.8
Tomcat 7
Yes, go to Project Properties >> Facets >> select Dynamic Web Module but dont apply yet!!!
Right under, it should appear a link Further Configuration Available. Click on it, otherwise one will have to edit .settings/org.eclipse.wst.common.component manually. Update source directory to src/main/java. (source)
Then in Facets window check Java - mine was pointing to 11 even though i don't have Java 11 installed or configured like a JRE runtime. I could only add/remove when changed to 1.8. (source). Note: That was really the problem, why don't Eclipse get this configuration automatically from the project?
Finally Eclipse creates some directories like WEB-INF and META-INF, just delete them.