This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 204303 - Ant using specified IDE-java instead of the java version one have set in the project
Summary: Ant using specified IDE-java instead of the java version one have set in the ...
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.0.1
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Tomas Zezula
URL: http://forums.netbeans.org/viewtopic....
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-27 08:55 UTC by Kkloe
Modified: 2012-04-12 07:03 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Ant diagnostic when running the project (9.28 KB, text/plain)
2011-10-27 08:55 UTC, Kkloe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kkloe 2011-10-27 08:55:09 UTC
Created attachment 112485 [details]
Ant diagnostic when running the project

Hallo there.

One of the applications that I am programming uses java 1.5 and previously been developed in netbeans 6.5 and Windows XP.
The enviorement where the application runs have java 1.5.

I have now installed Netbeans 7.01 and java 6 in my deveolping machine that runs on WIN 7.
I have installed Java 1.5 in a different folder to compile the application we have.
My current settings looks like the following as i am using and and maven:
Java:
Put JAVA_HOME as C:\Java1_5 and %JAVA_HOME%\bin in enviroment variables
Under Options->Misc->Profiler and Profiler Java Platform JDK 1.5 that points to the folder Java1_5
Under Projekt->Properties->Build->Compile says Java Platform 1.5
Maven:
Under Options->Misc->Maven:
Java1_5\apache-maven-2.0.9
Ant:
Put ANT_HOME as C:\Java1_5\apache-ant-1.7.1 and %ANT_HOME%\bin in enviroment variables
Under Options->Misc->Ant:
Java1_5\apache-ant-1.7.1
*Classpath
Java1_5\apache-ant-1.7.1\lib\maven-ant-tasks-2.0.9.jar

I can open the project without problems, compile it and such on but when we run as batches it seems that Ant still uses Java6 that comes with Netbeans when building and the servers that later run the application says there a missmatch in version number:
run-import:
[echo] ALCodeServerFTP started
[java] java.lang.UnsupportedClassVersionError: Bad version number in .class
file

When I open the Jars META-INF I see:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 20.0-b11 (Sun Microsystems Inc.)
Build-Date: September 5 2011
Main-Class: com.see.main_server.batch.rev.Main_App
Version: No Label September 5 2011
Class-Path: lib/log4j-1.2.14.jar lib/sqljdbc-1.2.jar lib/fw-1.1.8.jar
lib/activation-1.1.jar lib/mail-1.4.1.jar

when the older ones show:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 1.5.0_12-b04 (Sun Microsystems Inc.)
Build-Date: September 2 2011
Main-Class: com.see.main_server.batch.rev.Main_App
Version: No Label September 2 2011
Class-Path: lib/log4j-1.2.14.jar lib/sqljdbc-1.2.jar lib/fw-1.1.8.jar
lib/activation-1.1.jar lib/mail-1.4.1.jar

Running java -version or javac in command prompt displays:

java version "1.5.0_12-b04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)

javac 1.5.0_12-b04 

The only thing we can think of is that there is some bug with Netbeans 7.0.1 and 6.9.1 as we tried both thoose versions that Ant only uses the IDE-specified java instead of the java that the project have.

We also tried this now on 6.5.1 and it worked there without problem as it the Ant script built it with java5.
When running the ant script in netbeans 6.5.1
Detected Java version: 1.5 in: C:\Program Files (x86)\Java\jdk1.5.0_22\jre
Detected OS: Windows 7

Can also say that it works with Netbeans 6.7.1 and 6.8 if you choose to have Java5 as Netbeans IDE java.
Comment 1 Jesse Glick 2011-11-09 18:42:18 UTC
No instructions given to reproduce problem from scratch. Likely a user error. Check the source/target level setting on your project.
Comment 2 Kkloe 2012-03-28 09:09:44 UTC
Hallo,

I see there was missing a way to reproduce this error.

Import a project built with java 1.5 and uses ant into netbeans >= 6.9

Set all that the project compiles/builds with java 1.5 into a war file or similiar that uses ant to be created with.

Check what "Created by" java version it shows in the Manifest/META-INF.

win, or maybe not (:
Comment 3 Tomas Zezula 2012-03-28 09:39:25 UTC
The project selected platform is used for compiling and running the application, so the project is compiled with a compiler from selected platform executed on selected platform.
But the Ant script is executed by internal execution (it does not fork a new VM as it needs to see IDE classes and it's significantly faster).
So the "Created-By" is from Ant but both compiler and runtime comes from correct platform.
Comment 4 Kkloe 2012-04-12 07:03:58 UTC
As I dont have any java 1.5 environment to test this on I will have to take your word for it, then wouldn't it be still a bug that Ant writes the wrong "created by" ad should be fixed?

Need to report a new bug for this or?