adding jfxrt.jar to standard Eclipse build path - eclipse

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.

Related

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.

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 to restrict jdk api version in eclipse

I am using jdk1.6 in my eclipse build path. But i want to restrict the eclipse to show only those methods that is supported in jdk1.4.2. Is there anyway to do this.
Thanks.
Project properties -> Java build path -> Libraries tab.
Select your JDK/JRE, click Edit
Select "Execution environment", Select J2SE-1.4, click Finish, click OK
You might also want to set your JDK compliance level to 1.4, that's in Java Compiler in either project or workspace settings.

How do I attach source code locations to plugins in my Eclipse RCP target platform?

I've got a workspace with multiple RCP plugin projects.
We've set the target platform, so we can build against a standard set of plugins, but are not able to see source code and Javadoc for all the platform plugins.
The Windows -> Preferences -> Plug-in Development -> Target Platform -> Source Code Locations page doesn't seem to have any effect when I add the eclipse directory (it only allows you to add directories).
Copying the source jars from the eclipse directory into the target platform has a similar effect.
What am I doing wrong? How do I attach a set of Source jars to my target platform?
I had the same problem today. In my case I wanted to debug into the source of the plugin embedded jetty (org.mortbay.jetty_5.1.14.v200806031611.jar) which comes with Eclipse Equinox (OSGI) which is part of my eclipse target platform.
When debugged and wanted to go into any class inside a jetty package I always got the message that it is a class from Plugin-Dependencies and the source attachment cannot be modified.
I solved it like this:
Switch to the Plugins View in Eclipse ( Window / Show View / Plugins)
locate the bundle org.mortbay.jetty
right click on that bundle and select "Import as" -> "Binary Project with linked content"
Now that Bundle shows up in your Package Explorer as a new Eclipse project, in my case org.mortbay.jetty.
Now right click on that new project in the package explorer and goto 'Properties / Java Build Path / Libraries'. You see the the jetty jar file there and if you expand this entry you can edit the 'Source Attachment' as usual. I pointed it to the downloaded Jetty Source code located in a completely different folder than my target platform which I am using for my project.
If you use Eclipse SDK bundles when building your target platform, you should be immediately provided with "Java Source Attachment" and "Javadoc Location" for each Eclipse plugin.
For example, I used "Eclipse Platform SDK" (eclipse-platform-SDK-3.4.2-win32) as target space and when I display the "Source Code Locations page" that you mentionned, it is filled with "Source locations declared in the target platform". In the Eclise IDE, I can then see Eclipse core plugins source code and javadoc (in JFace packages for example).
Otherway, it is not so easy to add plugins source code locations but you can succeed it in 2 ways :
providing a "source plugin" (the easiest way if the plugin provider also supplies the source plugin) into the target platform, as an ordinary plugin (PDE will recognise it)
providing an additional source location (not the easy way ...)
You can find more information about Target Source Code Locations in you Eclipse Help, in the following topic :
Plug-in Development Environment Guide > Tools > Preferences > Target Platform Preferences > Source Code Locations
All sources are available if you download the 'Eclipse for RCP and RAP Developers' build from the main downloads page. At least, that's what it's called for the Juno build, it used to be called Eclipse for RCP/Plug-in Developers.
It doesn't look like the plugin source code is available via the standard Java/J2ee Eclipse builds any longer. I was assuming the sources would be available via the update mechanism but have been unable to find the correct update site/feature. If anyone knows, please comment.
I can modify the target platform at runtime, using the -install runtime option. Keep the targetPlatform as the eclipse platform.
However, this loses a lot of the benefits of using a target platform in the first place - i.e. compile time safety.