Compiling Java 11 code with maven-compiler-pugin 2.2 [duplicate]
up vote
1
down vote
favorite
This question already has an answer here:
Unable to compile simple Java 10 / Java 11 project with Maven
3 answers
I am trying to compile Java 11 code using maven-compiler-plugin 2.2, and it gives the following error:
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
projectstestoldmavensrcmainjavaMain.java:[10,14] error: cannot find symbol
projectstestoldmavensrcmainjavaMain.java:[11,8] error: cannot find symbol
I wonder if the reason is that either that I am doing something wrong or the problem is general and Maven 2 does not support Java 11 at all. Or are there maybe any workarounds that could help me compile Java 11 code using Maven 2?
I have tried to search for any reliable article that could directly state that Maven 2 does not support Java, or any minimal maven version requirement to run Java 11 code, or any maximum Java version which could be executed with maven-compler-plugin 2.x, but was not able to find anything helpful.
The code itself is just simple test with some Java 11 specific fragments:
public static void main(String args) {
Optional<Integer> value = Optional.empty();
final var id = 123;
var text = "This is the test of var & repeatrn";
System.out.println(text.repeat(2));
System.out.println(id * text.lines().count());
}
My pom.xml looks like this:
<groupId>1.0</groupId>
<artifactId>test-old-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<!--<version>3.6.1</version>-->
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
</properties>
If anyone could shed some light on my problem, that would be great. Thanks for any help in advance.
java compiler-errors maven-2 maven-compiler-plugin java-11
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 18:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
This question already has an answer here:
Unable to compile simple Java 10 / Java 11 project with Maven
3 answers
I am trying to compile Java 11 code using maven-compiler-plugin 2.2, and it gives the following error:
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
projectstestoldmavensrcmainjavaMain.java:[10,14] error: cannot find symbol
projectstestoldmavensrcmainjavaMain.java:[11,8] error: cannot find symbol
I wonder if the reason is that either that I am doing something wrong or the problem is general and Maven 2 does not support Java 11 at all. Or are there maybe any workarounds that could help me compile Java 11 code using Maven 2?
I have tried to search for any reliable article that could directly state that Maven 2 does not support Java, or any minimal maven version requirement to run Java 11 code, or any maximum Java version which could be executed with maven-compler-plugin 2.x, but was not able to find anything helpful.
The code itself is just simple test with some Java 11 specific fragments:
public static void main(String args) {
Optional<Integer> value = Optional.empty();
final var id = 123;
var text = "This is the test of var & repeatrn";
System.out.println(text.repeat(2));
System.out.println(id * text.lines().count());
}
My pom.xml looks like this:
<groupId>1.0</groupId>
<artifactId>test-old-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<!--<version>3.6.1</version>-->
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
</properties>
If anyone could shed some light on my problem, that would be great. Thanks for any help in advance.
java compiler-errors maven-2 maven-compiler-plugin java-11
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 18:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
Unable to compile simple Java 10 / Java 11 project with Maven
3 answers
I am trying to compile Java 11 code using maven-compiler-plugin 2.2, and it gives the following error:
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
projectstestoldmavensrcmainjavaMain.java:[10,14] error: cannot find symbol
projectstestoldmavensrcmainjavaMain.java:[11,8] error: cannot find symbol
I wonder if the reason is that either that I am doing something wrong or the problem is general and Maven 2 does not support Java 11 at all. Or are there maybe any workarounds that could help me compile Java 11 code using Maven 2?
I have tried to search for any reliable article that could directly state that Maven 2 does not support Java, or any minimal maven version requirement to run Java 11 code, or any maximum Java version which could be executed with maven-compler-plugin 2.x, but was not able to find anything helpful.
The code itself is just simple test with some Java 11 specific fragments:
public static void main(String args) {
Optional<Integer> value = Optional.empty();
final var id = 123;
var text = "This is the test of var & repeatrn";
System.out.println(text.repeat(2));
System.out.println(id * text.lines().count());
}
My pom.xml looks like this:
<groupId>1.0</groupId>
<artifactId>test-old-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<!--<version>3.6.1</version>-->
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
</properties>
If anyone could shed some light on my problem, that would be great. Thanks for any help in advance.
java compiler-errors maven-2 maven-compiler-plugin java-11
This question already has an answer here:
Unable to compile simple Java 10 / Java 11 project with Maven
3 answers
I am trying to compile Java 11 code using maven-compiler-plugin 2.2, and it gives the following error:
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
projectstestoldmavensrcmainjavaMain.java:[10,14] error: cannot find symbol
projectstestoldmavensrcmainjavaMain.java:[11,8] error: cannot find symbol
I wonder if the reason is that either that I am doing something wrong or the problem is general and Maven 2 does not support Java 11 at all. Or are there maybe any workarounds that could help me compile Java 11 code using Maven 2?
I have tried to search for any reliable article that could directly state that Maven 2 does not support Java, or any minimal maven version requirement to run Java 11 code, or any maximum Java version which could be executed with maven-compler-plugin 2.x, but was not able to find anything helpful.
The code itself is just simple test with some Java 11 specific fragments:
public static void main(String args) {
Optional<Integer> value = Optional.empty();
final var id = 123;
var text = "This is the test of var & repeatrn";
System.out.println(text.repeat(2));
System.out.println(id * text.lines().count());
}
My pom.xml looks like this:
<groupId>1.0</groupId>
<artifactId>test-old-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.2</version>
<!--<version>3.6.1</version>-->
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.release>11</maven.compiler.release>
</properties>
If anyone could shed some light on my problem, that would be great. Thanks for any help in advance.
This question already has an answer here:
Unable to compile simple Java 10 / Java 11 project with Maven
3 answers
java compiler-errors maven-2 maven-compiler-plugin java-11
java compiler-errors maven-2 maven-compiler-plugin java-11
asked Nov 8 at 13:44
Helen Zoykina
113
113
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 18:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by nullpointer
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 18:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02
add a comment |
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
By setting <maven.compiler.source>1.8</maven.compiler.source>
you are essentially passing -source 1.8
to the javac
compiler.
That is telling the compiler that you want to explicitly limit the input source code to Java 1.8 syntax and language. As you are using language constructs not defined in Java 8 (e.g. var
), it is going to fail.
As you are specifying release
as well, it appears that the value for source
is taking precedence.
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.
– Helen Zoykina
Nov 8 at 14:54
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
By setting <maven.compiler.source>1.8</maven.compiler.source>
you are essentially passing -source 1.8
to the javac
compiler.
That is telling the compiler that you want to explicitly limit the input source code to Java 1.8 syntax and language. As you are using language constructs not defined in Java 8 (e.g. var
), it is going to fail.
As you are specifying release
as well, it appears that the value for source
is taking precedence.
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.
– Helen Zoykina
Nov 8 at 14:54
add a comment |
up vote
1
down vote
accepted
By setting <maven.compiler.source>1.8</maven.compiler.source>
you are essentially passing -source 1.8
to the javac
compiler.
That is telling the compiler that you want to explicitly limit the input source code to Java 1.8 syntax and language. As you are using language constructs not defined in Java 8 (e.g. var
), it is going to fail.
As you are specifying release
as well, it appears that the value for source
is taking precedence.
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.
– Helen Zoykina
Nov 8 at 14:54
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
By setting <maven.compiler.source>1.8</maven.compiler.source>
you are essentially passing -source 1.8
to the javac
compiler.
That is telling the compiler that you want to explicitly limit the input source code to Java 1.8 syntax and language. As you are using language constructs not defined in Java 8 (e.g. var
), it is going to fail.
As you are specifying release
as well, it appears that the value for source
is taking precedence.
By setting <maven.compiler.source>1.8</maven.compiler.source>
you are essentially passing -source 1.8
to the javac
compiler.
That is telling the compiler that you want to explicitly limit the input source code to Java 1.8 syntax and language. As you are using language constructs not defined in Java 8 (e.g. var
), it is going to fail.
As you are specifying release
as well, it appears that the value for source
is taking precedence.
edited Nov 8 at 14:29
answered Nov 8 at 14:21
dan.m was user2321368
1,087513
1,087513
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.
– Helen Zoykina
Nov 8 at 14:54
add a comment |
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.
– Helen Zoykina
Nov 8 at 14:54
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:
[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
Thank you for the answer. The reason why I have put rows which refer to Java 8, is that without them I am not even able to compile Java 8 code, and get an error:
[INFO] Compilation failure error: Source option 1.3 is no longer supported. Use 6 or later. error: Target option 1.1 is no longer supported. Use 1.6 or later.
– Helen Zoykina
Nov 8 at 14:38
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
What happens if you change source/target to 11? And are you sure that the version of javac being invoked by maven is from the JDK 11? (E.g. does $JAVA_HOME point to JDK 11, and you haven't explicitly overridden that in a maven settings files)
– dan.m was user2321368
Nov 8 at 14:50
Thanks for your answer again, the code is compiling with some modified maven properties:
<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.– Helen Zoykina
Nov 8 at 14:54
Thanks for your answer again, the code is compiling with some modified maven properties:
<properties> <maven.compiler.target>11</maven.compiler.target><maven.compiler.source>11</maven.compiler.source></properties>
. I'll mark your answer as accepted as it helped to find the way to resolve the issue.– Helen Zoykina
Nov 8 at 14:54
add a comment |
I do not think this is a duplicate question, as in the article stackoverflow.com/questions/49398894/… Maven 3 is used, whereas this question is exactly about Maven 2
– Helen Zoykina
Nov 9 at 12:02