[SOLVED] CLASSPATH error after configuring JAVA Environment
Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
pathappend and pathprepend will not check the variable (that is made by the shell itself), but the value[s] passed to these functions. So for example in case of: pathappend /this/is/a/non/existent/dir the function will do nothing, will silently ignore it.
So creating these variables are not enough, those directories must be created before invoking pathappend.
I deleted everything at started again. Beforehand I also created /usr/share/java as suggested before that I have to create it myself but the problem still persists.
bash: ${AUTO_CLASSPATH_DIR}: invalid variable name
As soon as I did: source /etc/profile.d/openjdk.sh
ok, that was more or less expected.
What I can suggest you: execute bash -xv /etc/profile.d/openjdk.sh and post the full output without modification
I am doing this on the host machine itself due to hardware limitations so I don't know anyway to view the full output as there is no GUI or scroll bar. Can I send as much as I can see on the screen or is there any other way?
will write the output into /tmp/file and you can copy it anywhere. You can safely post a few lines here, but if it was more than 100 lines you can use pastebin (for example).
will write the output into /tmp/file and you can copy it anywhere. You can safely post a few lines here, but if it was more than 100 lines you can use pastebin (for example).
Code:
pathappend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
pathprepend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathremove () { local IFS=':';
local NEWPATH;
local DIR;
local PATHVARIABLE=${2:-PATH};
for DIR in ${!PATHVARIABLE};
do
if [ "$DIR" != "$1" ]; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR;
fi;
done;
export $PATHVARIABLE="$NEWPATH"
}
# Begin /etc/profile.d/openjdk.sh
# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk
+ JAVA_HOME=/opt/jdk
# Adjust PATH
pathappend $JAVA_HOME/bin
+ pathappend /opt/jdk/bin
+ pathremove /opt/jdk/bin
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=PATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin:/usr/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /opt/jdk/bin '!=' /opt/jdk/bin ']'
+ export PATH=/bin:/usr/bin
+ PATH=/bin:/usr/bin
+ local PATHVARIABLE=PATH
+ export PATH=/bin:/usr/bin:/opt/jdk/bin
+ PATH=/bin:/usr/bin:/opt/jdk/bin
# Add to MANPATH
pathappend $JAVA_HOME/man MANPATH
+ pathappend /opt/jdk/man MANPATH
+ pathremove /opt/jdk/man MANPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=MANPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/share/man '!=' /opt/jdk/man ']'
+ NEWPATH=/usr/share/man
+ for DIR in ${!PATHVARIABLE}
+ '[' opt/jdk/man '!=' /opt/jdk/man ']'
+ export MANPATH=/usr/share/man
+ MANPATH=/usr/share/man
+ local PATHVARIABLE=MANPATH
+ export MANPATH=/usr/share/man:/opt/jdk/man
+ MANPATH=/usr/share/man:/opt/jdk/man
# Auto Java CLASSPATH: Copy jar files to, or create symlinks in, the
# /usr/share/java directory. Note that having gcj jars with OpenJDK 8
# may lead to errors.
AUTO_CLASSPATH_DIR=/usr/share/java
+ AUTO_CLASSPATH_DIR=/usr/share/java
pathprepend . CLASSPATH
+ pathprepend . CLASSPATH
+ pathremove . CLASSPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=CLASSPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' . '!=' . ']'
+ export CLASSPATH=
+ CLASSPATH=
+ local PATHVARIABLE=CLASSPATH
+ export CLASSPATH=.
+ CLASSPATH=.
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done
+ for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -type d '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name
for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
pathappend $jar CLASSPATH
done
+ for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -name '"*.jar"' '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name
export JAVA_HOME
+ export JAVA_HOME
unset AUTO_CLASSPATH_DIR dir jar
+ unset AUTO_CLASSPATH_DIR dir jar
# End /etc/profile.d/openjdk.sh
Last edited by SINISTER750; 10-26-2020 at 03:16 PM.
pathappend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
pathprepend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathremove () { local IFS=':';
local NEWPATH;
local DIR;
local PATHVARIABLE=${2:-PATH};
for DIR in ${!PATHVARIABLE};
do
if [ "$DIR" != "$1" ]; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR;
fi;
done;
export $PATHVARIABLE="$NEWPATH"
}
# Begin /etc/profile.d/openjdk.sh
# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk
+ JAVA_HOME=/opt/jdk
# Adjust PATH
pathappend $JAVA_HOME/bin
+ pathappend /opt/jdk/bin
+ pathremove /opt/jdk/bin
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=PATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin:/usr/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /opt/jdk/bin '!=' /opt/jdk/bin ']'
+ export PATH=/bin:/usr/bin
+ PATH=/bin:/usr/bin
+ local PATHVARIABLE=PATH
+ export PATH=/bin:/usr/bin:/opt/jdk/bin
+ PATH=/bin:/usr/bin:/opt/jdk/bin
# Add to MANPATH
pathappend $JAVA_HOME/man MANPATH
+ pathappend /opt/jdk/man MANPATH
+ pathremove /opt/jdk/man MANPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=MANPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/share/man '!=' /opt/jdk/man ']'
+ NEWPATH=/usr/share/man
+ for DIR in ${!PATHVARIABLE}
+ '[' opt/jdk/man '!=' /opt/jdk/man ']'
+ export MANPATH=/usr/share/man
+ MANPATH=/usr/share/man
+ local PATHVARIABLE=MANPATH
+ export MANPATH=/usr/share/man:/opt/jdk/man
+ MANPATH=/usr/share/man:/opt/jdk/man
# Auto Java CLASSPATH: Copy jar files to, or create symlinks in, the
# /usr/share/java directory. Note that having gcj jars with OpenJDK 8
# may lead to errors.
AUTO_CLASSPATH_DIR=/usr/share/java
+ AUTO_CLASSPATH_DIR=/usr/share/java
pathprepend . CLASSPATH
+ pathprepend . CLASSPATH
+ pathremove . CLASSPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=CLASSPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' . '!=' . ']'
+ export CLASSPATH=
+ CLASSPATH=
+ local PATHVARIABLE=CLASSPATH
+ export CLASSPATH=.
+ CLASSPATH=.
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done
+ for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -type d '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name
for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
pathappend $jar CLASSPATH
done
+ for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -name '"*.jar"' '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name
export JAVA_HOME
+ export JAVA_HOME
unset AUTO_CLASSPATH_DIR dir jar
+ unset AUTO_CLASSPATH_DIR dir jar
# End /etc/profile.d/openjdk.sh
Though I had to type this all but I've checked it thoroughly, so there shouldn't be any mistakes. Here also it's written that variable name is invalid
Last edited by SINISTER750; 10-26-2020 at 11:53 PM.
but something different happened.
I don't know why, probably it is not bash but another shell which does not understand that backtick... or it is not a real backtick, but something else???
but something different happened.
I don't know why, probably it is not bash but another shell which does not understand that backtick... or it is not a real backtick, but something else???
Well, I checked the lines where the errors were found and they are no different than the output.
I'm using bash 5.0 as it is needed for BLFS 8.4
I should omit the $ sign.
but how can I change the output file? Will it make any difference? Do I have to make changes in the configuration file? If so then how can the BLFS book can go wrong?
Last edited by SINISTER750; 10-27-2020 at 09:25 AM.
as I wrote (in post #22) the backticks are not evaluated properly. I have no idea why. Probably because they are not real backticks.
you can try some simple scripts, like:
Code:
AUTO_CLASSPATH_DIR=/usr/share/java
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
echo "xxx${dir}yyy"
done
as I wrote (in post #22) the backticks are not evaluated properly. I have no idea why. Probably because they are not real backticks.
you can try some simple scripts, like:
Code:
AUTO_CLASSPATH_DIR=/usr/share/java
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
echo "xxx${dir}yyy"
done
to check what's going on
No good. I changed the script but again the same thing when I rebooted. No sorry! When I again checked it, no changes were made don't know why. I wasn't root.
Last edited by SINISTER750; 10-27-2020 at 10:11 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.