Tiina
Tiina

Reputation: 4797

intellij idea internal java compiler error

I am running a simple pattern matcher program exactly as in test_harness

Information:java: Errors occurred while compiling module 'demo_java8'
Information:javac 1.8.0_121 was used to compile java sources
Information:2018-02-06 10:15 - Compilation completed with 1 error and 0 warnings in 376ms
Error:java: Compilation failed: internal java compiler error

However terminal command javac xxx.java and java xxx run properly.

Running the first hello world program gives the same error.

Upvotes: 7

Views: 17156

Answers (4)

Roman Motovilov
Roman Motovilov

Reputation: 392

If you use a maven project and for example, you use java version as 1.8 please use this plugin where you specify which version you are using. Working example:

<dependencies>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 0

Vijay Nandwana
Vijay Nandwana

Reputation: 2644

In my case, the issue is resolved by adding a type parameter object to a class instance that needed it. In the following code replaced new ParameterizedTypeReference<> with new ParameterizedTypeReference<Map<String, Object>>

return getRestTemplate().exchange(uri,
                                  HttpMethod.POST,
                                  new HttpEntity<>(headers),
                                  new ParameterizedTypeReference<Map<String, Object>>() {

                                  });

Upvotes: 12

Tiina
Tiina

Reputation: 4797

It turned out that "odd" error description is because of maven plugin was missing. And it's default was 1.5 while Console class is only available since 1.6. Instead of jar or class cannot be found, it gives a blur description internal java compiler error. Information:javac 1.8.0_121 was used to compile java sources was a hint that the javac version and sdk version mismatch. Besides, I was surprised that intellij idea run function uses maven build (I thought it was just for cli) .

Upvotes: 3

jon
jon

Reputation: 1

If I have to guess, your IntelliJ is using the JDK packed with IntelliJ, try to set up your JDK for your project, in Project Structure make sure the JDK match your Java environment. JDK selection

Upvotes: 0

Related Questions