简体   繁体   中英

Java classpath issues on arch linux

For me to get any java program to run, I have to perform the following steps:

javac program.java
java -cp .  program

The output of echo $CLASSPATH is =/usr/share/java/
I was wondering why I have to manually specify the classpath everytime and how I can work around this issue. I am using archlinux with openjdk8. I encountered the same issue with openjdk9 as well.
Any help on the topic is appreciated.

You have set $CLASSPATH to /usr/share/java , so java will not look in the current directory anymore. To fix this, you can run unset CLASSPATH for temporarily unsetting the environment variable.

Depending on wheter or not you need $CLASSPATH pointing to /usr/share/java , you can either remove the offending line (something like export CLASSPATH=/usr/share/java ) or add the line export CLASSPATH=.:$CLASSPATH at the end of the file, wherever you set your environment variables (eg ~/.bashrc , ~/.zshenv , ...).

Cf. https://wiki.archlinux.org/index.php/environment_variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM