I use Eclipse
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600
and maven (mvn -v)
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
Maven home: C:\Daten\maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_60\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
my %JAVA_HOME% is set to
C:\Program Files\Java\jdk1.8.0_60
and my java is (java -version)
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
I run eclipse with -vm (java jdk version) and I added external maven installation in eclipse. after I imported a project and getting strang behaviour. Some classes are red in eclispe and some are not. I check with javap -version and they are all compiled with major version 52. I created new workspace and got the same result. very strange. If I open a "red" Java class with eclipse and just save it it gets ok (no compile errors).
I really dont know what is the problem.
Errors I get in eclipse
Syntax error on token "package", assert expected
Syntax error on token "import", throw expected
as a parent pom I use spring-boot-starter-parent with version 1.3.3-RELEASE I also specified all the properties I know like java.version, maven.compiler.source / target and project build source and output encoding. also tried to define maven compiler plugin. didn't help.
providing a code example
package com.test;
public class AExample {
public static void main(String[] args) {
System.out.println(args.length);
}
}
it looks like it is totaly dependend on the package I put the class in. with some package it is just compiling as normal with some it has the following erros
com.test cannot be resolved to a type AExample.java line 1
Illegal modifier for the local class AExample; only abstract or final is permitted AExample.java line 3
Syntax error on token "package", assert expected AExample.java line 1
Syntax error, insert "ClassBody" to complete ClassDeclaration AExample.java line 3
The nested type AExample cannot hide an enclosing type AExample.java line 3
the exact same class in a different package didn't produce that error. just in a specific package. any ideas what I can check?
Maven is a popular open-source build tool developed by the Apache Group to build, publish, and deploy several projects at once for better project management. The tool provides allows developers to build and document the lifecycle framework.
Maven is a popular open-source build tool that the Apache Group developed for building, publishing, and deploying several projects. Maven is written in Java and is used to create projects written in C#, Scala, Ruby, and so on. The tool is used to build and manage any Java-based project.
The Maven File Management API provides an API to collect files from a given directory using several include/exclude rules.
Apache Maven is a cornerstone of Java development, and the most used build management tool for Java. Maven's streamlined, XML-based configuration model enables developers to rapidly describe or grasp the outlines of any Java-based project, which makes starting and sharing new projects a snap.
Buried somewhere is probably a single actual compile error that's causing all the others. Focus on that. In my case, I had a file missing a }
. I was able to find the file by skimming the entire error list for errors that weren't Syntax error on token
or foo cannot be resolved to a bar
.
From the comments:
In my case, there was an unresolved conflict in another file. Apparently the eclipse-mars and/or java8 eclipse compiler fails to compile/build other files in a meaningful manner after some types of compile errors in dependent files, instead spouting what appears to be gibberish errors for the files that can't be built do to the bad dependency
(This answer based on Richard Sitze's comment, for anyone else who finds this question in the future.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With