Closed Riduidel closed 1 year ago
Being a noob un LUA, I tried an implementation
-- This is the prompt module function.
local function java_module(args)
local version_output = io.popen("java -version 2>&1")
for line in version_output:lines() do
local version = line:match('^java version "(.*)" .*$')
if version then
return " " .. version, "blue"
end
end
version_output:close()
return "", "magenta"
end
flexprompt.add_module("java", java_module)
Unfortunatly, it only works when java is defined in system PATH, but not in USER path. Any idea why?
Unfortunatly, it only works when java is defined in system PATH, but not in USER path. Any idea why?
@Riduidel What is meant by "USER path"? Do you mean when Java is installed in %USERPROFILE%, and the Java directory is not on the system PATH? How do you normally use Java when the Java directory isn't on the system PATH?
@Riduidel I realized that "SYSTEM path" and "USER path" probably refer to the "System variable" and "User variables" sections in the "Environment Variables" dialog box in the System Properties page of Windows Settings.
If that's the case, then something is running as an Administrator -- an Elevated process or system process. That would be an external issue, due to the configuration being used on the computer. I couldn't guess at specifics, because I know nothing about the computer or its configuration.
Java version can be obtained by running
java -version
Which return a line such asFor an example implementation, starship shell java module uses a Rust regular expression for that:
(?:JRE.*\\(|OpenJ9 )(?P<version>[\\d]+(?:\\.\\d+){0,2})