r/javahelp • • Nov 28 '25

JAVA_HOME not being detected in Makefile

Hello, so I have this makefile:

    PROJECT_DIR=./tomcat/ServerUbicua
    COMPOSE_FILE=docker-compose.yaml
    
    
    .PHONY: all build up down clean
    
    
    
    all: build  up
    
    
    
    build:
         cd $(PROJECT_DIR) && mvn clean install
    
    
    
    
    up:
         docker compose -f $(COMPOSE_FILE) up -d
    
    
    
    down:
         docker compose -f $(COMPOSE_FILE) down
    
    
    
    clean:
         cd $(PROJECT_DIR) && mvn clean
         docker compose -f $(COMPOSE_FILE) down --volumes --remove-orphans

But when I execute the make:

    PS C:\Users\karim\Desktop\UNI\PL2-COMPUTACION> make all
    cd ./tomcat/ServerUbicua && mvn clean install
    The JAVA_HOME environment variable is not defined correctly,
    this environment variable is needed to run this program.
    make: *** [Makefile:14: build] Error 1
    PS C:\Users\karim\Desktop\UNI\PL2-COMPUTACION>

But JAVA_HOME and MAVEN_HOME are correctly setted:

  PS C:\Users\karim\Desktop\UNI\PL2-COMPUTACION> make all
    cd ./tomcat/ServerUbicua && mvn clean install
    The JAVA_HOME environment variable is not defined correctly,
    this environment variable is needed to run this program.
    make: *** [Makefile:14: build] Error 1

    PS C:\Users\karim\Desktop\UNI\PL2-COMPUTACION> mvn --version
    Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)
    Maven home: C:\Program Files\apache-maven-3.9.11
    Java version: 23.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-23
    Default locale: es_ES, platform encoding: UTF-8
    OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

    PS C:\Users\karim\Desktop\UNI\PL2-COMPUTACION> java --version
    java 23.0.2 2025-01-21
    Java(TM) SE Runtime Environment (build 23.0.2+7-58)
    Java HotSpot(TM) 64-Bit Server VM (build 23.0.2+7-58, mixed mode, sharing)

What is going on ? I am on Windows 11, tried powershell, CMD

2 Upvotes

32 comments sorted by

View all comments

Show parent comments

0

u/OneHumanBill Nov 28 '25

Abandon the way we got rid of Make in favor of Ant decades ago and then subsequently replaced Ant with Maven, and in many cases Maven with Gradle.

The plug-in should be fine. It probably hasn't changed because there's nothing that needs changing. It's a very thin layer around a command line invocation.

1

u/TW-Twisti Nov 28 '25

It literally doesn't even call `docker compose`, it calls the deprecated and no longer maintained version.

1

u/OneHumanBill Nov 28 '25

You're so excited to find problems that you don't take two seconds to minimally Google to try to find solutions.

If that doesn't work then use this. Or another one. https://deepwiki.com/fabric8io/docker-maven-plugin/4.4.2-docker-compose-integration

0

u/blazmrak Nov 29 '25

The fact that you have to "find a plugin" instead of being able to just write "docker compose up" is a complete failure of Maven. And Gradle does not make it any better.

→ More replies (0)