1

I have a starter spring boot Hello World program, which is throwing the following error:

No Java compiler available for configuration options compilerClassName: [null] and compiler: [null]

I issue is ONLY in Mac and not in windows PC. On my Mac I have tried using both Eclipse and IntelliJ IDEA CE. I have looked at these 2 posts here:

How to resolve java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName

No Java compiler available for configuration options compilerClassName: [null] and compiler: [null]

But these solutions won`t work me.

I am posting my code here: pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mohnish</groupId>
<artifactId>spring-boot-maven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>spring-boot-maven</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Add this -->
    <dependency>
        <groupId>org.eclipse.jdt.core.compiler</groupId>
        <artifactId>ecj</artifactId>
        <version>4.6.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>



</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Controller:

package com.mohnish.springbootmaven;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class HelloController {

@GetMapping("/")
public String hello() {
    return "hello";
 }
}

Configuration:

package com.mohnish.springbootmaven;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import   org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class SpringBootMavenApplication  extends         SpringBootServletInitializer {

public static void main(String[] args) {
    SpringApplication.run(SpringBootMavenApplication.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(SpringBootMavenApplication.class);
}
}

Jsp Page:

<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Hello</title>
</head>
<body>
    Hello World!
</body>

</html>

and Finally my application.properties:

spring.mvc.view.prefix=/WEB-INF/jsp
spring.mvc.view.suffix=.jsp

I have also tried moving the jsp file to /WEB-INF/ instead of /WEB-INF/jsp.

Any pointer will be appreciated. Thanks.

shortduck
  • 1,437
  • 1
  • 8
  • 13
  • Possible duplicate of [How to resolve java.lang.IllegalStateException: No Java compiler available for configuration options compilerClassName](https://stackoverflow.com/questions/45937784/how-to-resolve-java-lang-illegalstateexception-no-java-compiler-available-for-c) – Isaac Betesh Jul 10 '18 at 17:01

0 Answers0