The java-version command cannot be used unless you are a superuser.

Asked 2 years ago, Updated 2 years ago, 42 views

Commands for Verifying the Version of java

java --version

When entering at the terminal, even if it is an account with admin privileges, nothing happens unless you enter sudo first.

Also, if you enter a command when using the protector, it will be the same phenomenon. Is there any other solution?

OS INFO

ProductName: Mac OS X
ProductVersion: 10.12.3

Results of ls-la at /usr/bin/ (same for Admin and guest users)

 (java)
lrwxr-xr-x1 root wheel 74 Feb 18 13:31 java->/System/Library/Frameworks/JavaVM.framework/Version/Current/Commands/java
(javac)
lrwxr-xr-x1 root wheel 75 Feb 18 13:31 javac->/System/Library/Frameworks/JavaVM.framework/Version/Current/Commands/javac

Which java Results

/usr/bin/java

type java results

 java is hashed (/usr/bin/java)

/usr/bin/java-version Results

Stay in standby and nothing is displayed.Ctrl-C must be stopped to enter the next command

By the way, when I tried it as a guest user, the version was displayed without sudo without any problems.

java macos

2022-09-30 18:20

1 Answers

As a hard-line measure, I saved my whoami username after doing sudo visudo as follows:

Username ALL=(ALL)ALL

After the above configuration, I could use it without sudo, but when I commented out the lines I tried to add later and ran java-version, I was not sure why, but the version was displayed.
I don't know what caused it, but

This post was posted as a community wiki based on @ynbenson's comments.


2022-09-30 18:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.