0

For whatever reason I had to change pc's as a result of the change I now have to use Java 6 (the final update) Instead of java 7. When importing my existing project to Java 6 I get the following error in my auto generated code that was generated by Netbeans and is not modifiable

cannot find symbol

symbol: variable Type

location: class Window

    frame.setType(java.awt.Window.Type.POPUP); //Type is underlined

The output for the error is as follows:

javac: invalid target release: 1.7
Usage: javac <options> <source files>
use -help for a list of possible options
C:\Users\Adminstrator\Downloads\NetBeansProjects\NetBeansProjects\Pat0.3\nbproject\build-impl.xml:915: The following error occurred while executing this line:
C:\Users\Adminstrator\Downloads\NetBeansProjects\NetBeansProjects\Pat0.3\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.

What does this do? Is it necessary, would deleting that the component help? Which component is it, is there a quick fix?

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Ayvadia
  • 339
  • 1
  • 4
  • 19
  • Why don't you simply install Java 7 then? You're administrator, you should be able to. Also: Java 6 is approach its end of life. – Joachim Sauer Oct 07 '13 at 17:58
  • @JoachimSauer Well I did have Java 7 then my teacher said that he would not accept Java 7.3 so I tried installing java 7.2(his copy) and the install failed and all the versions of java i had broke so after "cleaning up java 6 was the only update that worked also I have a limited bandwidth – Ayvadia Oct 07 '13 at 18:02
  • Actually i used the other pc because of the messed up java builds – Ayvadia Oct 07 '13 at 18:04
  • There is no "Java 7.3" or "Java 7.2" so I don't know what you're talking about. There's only "Java 7" (with updates 1 to 40 (with some holes), but those don't change the language in any way). You might be talking about Netbeans versions, are you? – Joachim Sauer Oct 07 '13 at 18:05
  • open netbeans and change project plattform and put java 6. – nachokk Oct 07 '13 at 18:05
  • not sure as I am using Eclipse, but in eclipse you can change the execution environment by installing java in separate directory and then pointing to it. – Rupesh Oct 07 '13 at 18:08
  • Sorry my mistake Netbeans 7.3 not Java 7.3 – Ayvadia Oct 07 '13 at 18:09
  • @Ayvadia: which version of Netbeans you use to write your code should not matter, as long as you use a Java version that's compatible with your teachers (which you seem to do) and are not using the Netbeans platform libraries (pretty unlikely). – Joachim Sauer Oct 08 '13 at 07:55
  • @JoachimSauer Would using DB Apache mean I'm using The Netbeans platform libraries?? – Ayvadia Oct 08 '13 at 12:50
  • "DB Apache"? There's no such thing. Are you talking about JavaDB or Apache Derby? In both cases: no, it doesn't. JavaDB is provided with the JDK (but not the JRE) and Apache Derby is a open source project that's independent of both the JDK and Netbeans (and on which JavaDB is based). – Joachim Sauer Oct 08 '13 at 12:52

2 Answers2

2

Your build.xml specifies the target="1.7" flag to javac, which java 6 doesn't know how to interpret. Changing it to 1.6 will technically get past that error.

However, the enum Window.Type was added in Java 7, so you simply can't expect changing the target to work; your project's source uses Java 7 features. I'm sure that's not the only one.

Your options are therefore to methodically go through and remove/replace all Java 7 code (likely introducing some bugs) or just to.. install Java 7.

roippi
  • 25,533
  • 4
  • 48
  • 73
0

There is somewhere in your project a setting for the java compiler that tells it to generate classes for jre7. javac from jdk6 cannot generate classes for that version, hence the error. So you should look into the properties of your project and set up javac to generate classes for jr6. You might also have fix some of your non-generated code if for example you have used features that came with java 7 such as diamond operator or multy catch block etc.

Also the javadoc for Window.Type states it is available only since 1.7. You might want to re-generate that code or better yet just install jdk7.

A4L
  • 17,353
  • 6
  • 49
  • 70