Stephane
Stephane

Reputation: 12810

No version set for command java - asdf

I'm now using asdf on my Lubuntu machine in a bash environment and it gives me the message:

stephane@stephane-pc:~/dev$ cd
No version set for command java
Consider adding one of the following versions in your config file at 
java adoptopenjdk-15.0.2+7

I have only one asdf project which is located in the ~/work/example/dev/ExampleBooster directory:

12:07 $ cat .tool-versions 
java adoptopenjdk-15.0.2+7
nodejs 12.13.1
tflint 0.28.1
terraform-validator 3.1.3
packer 1.7.2
terraform 0.15.3
adr-tools 3.0.0
pre-commit 1.21.0
maven 3.8.4

My asdf configuration ~/dev/commands/asdf.config.sh file contains:

#!/bin/bash -x

source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash
# Setting the JAVA_HOME variable
. ~/.asdf/plugins/java/set-java-home.bash

# If asdf provides the maven plugin then use the plugin instead of the system maven if any
if asdf current maven > /dev/null 2>&1; then
  export MAVEN_HOME=$(asdf where maven)
  export PATH=$PATH:$MAVEN_HOME/bin
fi

UPDATE: I added the line java adoptopenjdk-15.0.2+7 in the ~/.tool-versions file and that solved the issue.

Upvotes: 3

Views: 10305

Answers (1)

JRichardsz
JRichardsz

Reputation: 16584

I tried locally and it worked as expected.

Steps

Install required tools:

apt-get update -y && apt-get -y  install curl git dirmngr gpg gawk && git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1 && . $HOME/.asdf/asdf.sh

Add java plugin

asdf plugin add java https://github.com/halcyon/asdf-java.git

Install it

asdf install java adoptopenjdk-15.0.2+7

Config it

asdf global java adoptopenjdk-15.0.2+7

After the previous steps, java is ready to use and it appears in the $HOME/.tool-versions

java with asdf

I didn't need any other configuration to get Java on the system.

Docker

Just to try or determinate that your system could be misconfigured, you could use docker to have a fresh and temporary ubuntu. In this environment you could try asdf from the scratch:

docker run -it ubuntu bash

Sources

Upvotes: 5

Related Questions