r/javahelp • u/Federal-Dot-8411 • 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-orphansBut 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
View all comments
Show parent comment
1
u/blazmrak Nov 28 '25
This is a stupid question, but can you run mvn clean install on your own? If so, then this has to be a Make and you will have to set JAVA_HOME explicitly. I'm not familiar with it, but it could be (and it would make perfect sense) that it doesn't pass any environment variables to the tasks and that you have to define them yourself in the makefile
Edit: just scrolled to the bottom and saw https://www.reddit.com/r/javahelp/comments/1p8t5r8/comment/nr8evp2/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button - I think this is most likely