Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory


(Annie Viviane Lessa) #1

Good afternoon.
I’m having the following problem when I try to run tomcatRun:

Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

I think it might be my build.gradle. Estou usando Java JDK 10.0.2 e Gradle 4.9 com banco de dados PostgreSql.
Here is my gradle:

buildscript {
ext {
springBootVersion = ‘2.0.4.RELEASE’
}
repositories {
mavenCentral()
}

dependencies {    
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'        
}

}

import groovy.sql.Sql
task queryTest () {
configurations {
jdbc
}

dependencies {    
    jdbc 'org.postgresql:postgresql:42.2.0'
}

doLast {    
    def sqlClassLoader = Sql.classLoader
    configurations.jdbc.each { sqlClassLoader.addURL it.toURI().toURL() }

    def driver = 'org.postgresql.Driver'
    def dburl = "jdbc:postgresql://localhost:5432/cadastro"
    def first
    Sql.withInstance(dburl, 'postgres', 'masterkey', driver) {
        sql ->
            first = sql.firstRow( "SELECT * FROM users" )
    }
}

}

apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘war’
apply plugin: ‘eclipse-wtp’
apply plugin: ‘com.bmuschko.tomcat’
apply plugin: ‘org.springframework.boot’
apply plugin: ‘io.spring.dependency-management’

jar {
baseName = ‘jsf-primefaces-example’
version = ‘0.1.0’
}

eclipse {
project {
natures ‘org.springsource.ide.eclipse.gradle.core.nature’, ‘org.eclipse.jdt.groovy.core.groovyNature’, ‘org.eclipse.wst.common.project.facet.core.nature’
}

classpath {	
	containers 'org.springsource.ide.eclipse.gradle.classpathcontainer'		
}

wtp {	
	facet {		
	  facet name: 'jst.web', version: '3.0'
	  facet name: 'java', version: '1.7'		  
	}
}

jdt {	
	sourceCompatibility = 1.7
	targetCompatibility = 1.7		
}

}

repositories {
// jcenter() ou mavenCentral()
mavenCentral()
}

dependencies {
def tomcatVersion = ‘9.0.10’
tomcat “org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}”,
“org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}”,
“org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}”

compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')

compile('com.h2database:h2')

testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')

compile('com.fasterxml.jackson.core:jackson-databind')

compile('javax.servlet:javax.servlet-api')
providedCompile("javax.servlet:javax.servlet-api:3.1.0")    

}

Can anybody help me? Appreciate.


(GradleEval) #2

Spanish spotted ^^

I suppose you are Under eclipse when you have this message ? If so start eclipse with the jdk.

Add this line to your eclipse.ini file before vmargs if any

-vm
C:\Java\JDK\1.8\bin\javaw.exe

From here for full explanation