问题
I am transferring a project source from one pc to another. When I click Clean and Build Main Project
from Run
Menu of Netbeans, I got this error:
init:
deps-clean:
Updating property file: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\built-clean.properties
Deleting directory E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build
clean:
init:
deps-jar:
Created dir: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build
Updating property file: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\built-jar.properties
Created dir: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\classes
Created dir: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\empty
Created dir: E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\generated-sources\ap-source-output
Compiling 2 source files to E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\build\classes
javac: invalid target release: 1.7
Usage: javac <options> <source files>
use -help for a list of possible options
E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\nbproject\build-impl.xml:605: The following error occurred while executing this line:
E:\Backup\My Documents (BackUp)\NetBeansProjects\AccountStatusChanger\nbproject\build-impl.xml:246: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
what will I do? Do i need to reinstall the SDK?
回答1:
It looks as if the original machine has JDK 7 installed and the project was configured with that as the target, but the second machine has an older version.
- You can configure the project to target 1.6 or 1.5,
or
- If you need JDK 7 then you'll have to install it in the second machine.
回答2:
As @madth3 said, the problem is with the project build target version. The source you have imported is target for JDK 7 platform. Either you install JDK 7 on you system or change the project build target to JDK 1.6.
To change the target platform:
- Right click on the project node, select properties,
- Under "sources" in the properties window, change "source/binary format" to the desired platform
来源:https://stackoverflow.com/questions/9629006/error-while-building-project-in-netbeans