Ant ran from MyEclipse not using the "default" JRE - eclipse

I am working as a contractor, and they are using MyEclipse 10.0 with Ant to do builds. Its been a LONG time since I used Ant as the build tool, as I have primarily been on Maven for some time.
Their source are broken into multiple projects, and each links back to a common project that has a commone build.xml that is imported by each project's build.xml. The ant script is used to WAR the app and do deployments both locally and on their Test environment using WebLogic's java-based deployment tools. They are using WebLogic 9.2, which, from what I read, has issues with JDK 1.6 and higher. I have set the 1.5 JDK/JRE as the default inside MyEclipse in Preferences->Installed JREs.
For all the projects, when I launch the Ant target from within Eclipse it runs under the 1.5 JDK/JRE I set as the default. But for this one project it seems to insist on running under the 1.6 JDK that ships as part of MyEclipse 10. If I right-click on the Ant build in the Ant view/tab and look at the properties for the Run Configuration (right click, Run As->External Tool Configuration...), the JRE selected shows the 1.5 JDK/JRE. But alas, when I run it it STILL is running under the 1.6 JDK.
Any thoughts?

Search your Ant files for the string fork. It might be that one of the Ant tasks itself starts a new VM.

It turns out, even though Eclipse was reporing the JDK set to 1.5, it wasn't. I went into Run As->External Tools..., set it to 1.6, saved, then set it back to 1.5...poof! now it works.

Related

Can we use different JDK's for Spring tool Suite based on eclipse and eclipse luna

I have some projects in my eclipse Luna that are based on Java 1.6 and I am trying to learn the latest spring boot which uses Java 1.8 , I am learning spring boot on spring tool suite which is based out of eclipse ,I tried installing Java 1.8 in my system and I have successful install both 1.6 and 1.8 Java in my system but when I try to open Spring tool suite it says JDK version should be 1.8 or higher I know I have the classpath set as 1.6 but is there anyway we can set the classpath 1.6 for eclipse Luna and Java 1.8 classpath for spring tool suite because I constantly change over projects as because Java 1.6 is my production environment in Java 1.8 is something like a test where I am trying to learn spring tool suite.
Is there any way we can achieve this without having to change the classpath everytime I Switch between spring tool Suite and eclipse Luna
The first thing to understand is that Eclipse itself requires a JRE to run (preferably a JDK), and that JRE can be different than the one that your projects in Eclipse are configured to use - they are intentionally separate.
To specify the JRE that Eclipse itself runs in, you should specify it in eclipse.ini. Read that page carefully, the format is very particular. Once you've done that, your system classpath or JAVA_HOME or PATH will not matter, Eclipse prefers its own ini settings.
With that done, the default JRE/JDK used for your projects in Eclipse will be the same as the one Eclipse itself is running in. But that's only the default, you can add more JRE/JDKs and configure individual projects to use them.
The point is, each instance of Eclipse can be configured to run in a particular JRE/JDK you have on your system (although there's really no reason not to use the latest for running all Eclipse instances), and then within each Eclipse instance, each project can be configured to use a specific JRE/JDK (which may or may not be the same one that that Eclipse instance is running in).
For example, you should probably configure both Eclipse Luna and STS to use the JDK 8 you have, via their .ini files. Then in Luna you can add a JRE config for JDK 1.6 on your system and set projects to use that one. The projects don't have to use the same JRE/JDK that Eclipse itself is running in.

No version prompt when running maven-release-plugin inside Eclipse

When I run maven release:prepare from the command line I'm prompted for the release version, developer version and SCM tag. This is good. What is not so good is when I do the same from inside Eclipse. Using an m2e run configuration I set the same goal but instead of prompting me for the version information it automatically sets them to some defaults. The defaults are pretty good but sometimes I want explicit control.
There are many developers on this project and asking them to drop out to command lines or fiddle with shared run configurations is not ideal. Maybe this has nothing to do with the Maven Release Plugin and is more to do with input prompts in general. Are there any other examples of Maven plugins prompting for input during execution inside Eclipse?
I'm using SpringSource Tool Suite 2.9 (old!) configured to use an external Maven 3.0.3 with m2e 0.12.1.
This is normal. The Eclipse plugin for Release will automatically release the version set in your POM, and set the next development version to +0.0.1 of that.
I'm used to using the release plugin from inside Eclipse, and when I used it from command prompt I was surprised when I was prompted for version :p

How Can I Tell Eclipse to Compile and Build a Project with a Different JRE Version than it Normally Does?

I'm not sure if this question has been answered in full or if my title is descriptive enough given my situation, but I've been asked to convert a project from being built with Ant to Maven. That part isn't too bad, but I've been told that this application was designed specifically for the JRE version 1.5 rather than the JRE 6 everything else I've been dealing with uses. Now, I'm incredibly new to Eclipse and Java themselves, so I was a bit confused when I was asked to tell either Eclipse or Maven to build this particular project using the JRE 1.5 instead. I have it installed, I believe, and I've tried to follow the steps outlined here: ( Eclipse: Build and conform to different JRE versions ), but I've run into a snag.
I've managed to change the Run Configuration to use the Alternate JRE jre1.5.0_11. When I then tried to build it, the console spat out the following:
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files (x86)\Java\jre1.5.0_11\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
I assume this means that I need to be using the JDK 1.5 in order to use the JRE 1.5, since I'm currently working with JDK 1.6. Now, is there a way to install the JDK 1.5 so that this project can use it? My JAVA_HOME variable currently points to the JDK 1.6, and I would like it to stay that way... Is there a way to be able to use both and simply tell the project (or Eclipse or Maven... however it works) to use a specific version of the JDK?
Yes, this is possible. You can install as many different versions of Java — JREs and JDKs — as you like, and tell Eclipse which one to use for each project.
First step is to install the JDK 1.5 on your machine (JDK is short for 'Java [SE] Development Kit', look for that on the Oracle download site). The JDK includes a JRE, so to make life easier you can usually just install the JDK and not worry about the JRE/JDK distinction.
Second step is to tell Eclipse about the new JDK. Go to Preferences... then Java > Installed JREs. Click the Search... button and Eclipse should find your newly installed JDK 1.5 and add it to the list.
Final step is to allocate that JDK 1.5 to your project. Bring up the Properties menu for your project (right-click it). Then set these values:
Java Compiler tab
Tick Enable project specific settings
Set Compiler Compliance level to 1.5
Java Build Path tab, Libraries subtab
Find the JRE System Library item, click Edit...
Set Alternate JRE to your newly installed JDK 1.5
It looks like you are using JRE 1.5 rather than JDK 1.5
Make sure you download the JDK 1.5 and your issue should go away. You can set the default JDK in the preferences, search for 'jre'.
Projects can also define their specific jre
Get JDK 1.5 from Here http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html

Does Eclipse ship ant with its own distribution?

First time using Apache Ant (I'm excited and overwhelmed at the same time!) for automating a Java app.
I did not go to the ant website and download ant directly. Rather, I'm using the standard plugin that ships with Eclipse. From Eclipse, I can run test build.xml projects perfectly. But when I go to run ant directly off the command-line, Windows doesn't recognize it as a recognized command.
This leads me to believe that I either do not have ant installed, or I have not configured it properly (at all). If it's not installed, then why do these build.xml scripts work when I fire them inside of Eclipse? Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?
And if it's just a config issue, what do I need to do in order to get ant to run a buildscript of my own flavor?
I want to start using Apache Ivy and in order to run the demos I first need ant up and running from the command line.
Thanks for any help or insight :-)
Does Eclipse ship with its own distrib of ant that isn't accessible from the cmd line?
Essentially, yes. Eclipse bundles the core Ant runtime plus its own extensions and integration, but it's private to the Eclipse installation.
If you want to run the builds from outside of Eclipse, you need to download and install the full distribution of Ant.

Where is mvn.exe when using embedded maven 3 in eclipse indigo?

I'm using the Indigo Release of eclipse. When I check Window -> Preferences, Maven -> Installations, it confirms that it's using the Embedded (3.0.2/...) installation of Maven.
I want to be able to run maven commands from the command line (Windows Powershell), but when I type, e.g.,
PS C:\> mvn
no executable is found. I did a search for "mvn.exe" and found no results.
I suppose I could install a stand-alone version of Maven 3 and add that to my PATH, but I'd prefer to be using the same Maven installation for command line tasks as well as IDE (eclipse) tasks.
So, where is the embedded maven's mvn.exe hiding?
The simple answer is, cause it's embedded in Eclipse so you can't call it from console. If you like to do this you have to install Maven yourself.
There is no mvn.exe at all. The Maven distro comes with batch or shell scripts. Eclipse runs an embedded version which is called through an API.
remember, embedded maven is not configured to work out of eclipse environment (and terminal usage is out of STS usage).
we have to install maven.
and also note, there is no "mvn.exe"
follow the following to setup maven to work from terminal.
maven download link is here
download latest maven from here
extract it where ever you want.
i extracted as below (see the bin,boot,conf,... folders are shown below as in the image):
as this maven download is extracted from zip file (it is not setup), you will have to add this extracted path to "PATH" variable in windows environment.
follow this to set environment path:
now "mvn" command must work.
in my case, i use STS (spring tool suite)
and i had to restart STS for "mvn" to work in terminal in sts.
check it out with eclipse.