LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   CLASSPATH error after configuring JAVA Environment (https://www.linuxquestions.org/questions/linux-from-scratch-13/classpath-error-after-configuring-java-environment-4175684232/)

SINISTER750 10-26-2020 03:58 AM

CLASSPATH error after configuring JAVA Environment
 
I'm installing BLFS 8.4
After configuring JAVA Environment (binary), when I reboot the system a message is being displayed:

-su: ${AUTO_CLASSPATH_DIR}: invalid variable name.
-su: ${AUTO_CLASSPATH_DIR}: invalid variable name.

echo $CLASSPATH shows "."
I have set:
AUTO_CLASSPATH_DIR=/usr/share/java
JAVA_HOME=/opt/jdk
as per the book.
All the certificates are displayed properly.

Please help. Thank you.

business_kid 10-26-2020 05:46 AM

Have you checked things?

Code:

echo $AUTO_CLASSPATH_DIR && ls -lha /usr/share/java

SINISTER750 10-26-2020 07:29 AM

Quote:

Originally Posted by business_kid (Post 6178893)
Have you checked things?

Code:

echo $AUTO_CLASSPATH_DIR && ls -lha /usr/share/java

I ran the above code, the output of the first half is nothing (blank) and of the second half is: No such file or directory

SINISTER750 10-26-2020 07:46 AM

http://www.linuxfromscratch.org/blfs...ojdk-conf.html

Here is the link of the section for commands to configure JAVA Environment

Keith Hedger 10-26-2020 09:04 AM

Why such an old version? LFS is at 10.0 now

SINISTER750 10-26-2020 09:20 AM

Quote:

Originally Posted by Keith Hedger (Post 6178946)
Why such an old version? LFS is at 10.0 now

Due to hardware limitations brother.
I have a very old laptop and I want to study linux.
Please help me with my problem!

Keith Hedger 10-26-2020 09:53 AM

Quote:

Originally Posted by SINISTER750 (Post 6178952)
Due to hardware limitations brother.
I have a very old laptop and I want to study linux.
Please help me with my problem!

You probably should have included that info in your post the more info we get the easier it is to help.

Keith Hedger 10-26-2020 10:00 AM

Quote:

Originally Posted by SINISTER750 (Post 6178863)
I'm installing BLFS 8.4
After configuring JAVA Environment (binary), when I reboot the system a message is being displayed:

-su: ${AUTO_CLASSPATH_DIR}: invalid variable name.
-su: ${AUTO_CLASSPATH_DIR}: invalid variable name.
...

Need to know where this error is being generated , what comes before and after it?

SINISTER750 10-26-2020 10:24 AM

Quote:

Originally Posted by Keith Hedger (Post 6178967)
Need to know where this error is being generated , what comes before and after it?

The message is displayed after everytime I reboot or login to normal user or use the command: source /etc/profile.d/openjdk.sh
It only displays those two messages are written in the previous comments and nothing else.
What I do not understand is why /usr/share/java directory is not being created after the variable has been set whereas JAVA_HOME is working fine!

pan64 10-26-2020 10:32 AM

Quote:

Originally Posted by SINISTER750 (Post 6178973)
The message is displayed after everytime I reboot or login to normal user or use the command: source /etc/profile.d/openjdk.sh
It only displays those two messages are written in the previous comments and nothing else.
What I do not understand is why /usr/share/java directory is not being created after the variable has been set whereas JAVA_HOME is working fine!

would be nice to see the content of that /etc/profile.d/openjdk.sh

SINISTER750 10-26-2020 10:37 AM

Quote:

Originally Posted by pan64 (Post 6178975)
would be nice to see the content of that /etc/profile.d/openjdk.sh

Code:

cat > /etc/profile.d/openjdk.sh << "EOF"
# Begin /etc/profile.d/openjdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend $JAVA_HOME/bin

# Add to MANPATH
pathappend $JAVA_HOME/man MANPATH

# 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

pathprepend . CLASSPATH

for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
    pathappend $dir CLASSPATH
done

for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
    pathappend $jar CLASSPATH
done

export JAVA_HOME
unset AUTO_CLASSPATH_DIR dir jar

# End /etc/profile.d/openjdk.sh
EOF

These are the contents of /etc/profile.d/openjdk.sh

This should be correct, I double checked what I typed from the BLFS book.

Keith Hedger 10-26-2020 10:45 AM

/usr/share/java is not created automatically, create it when you need to put jar files in it

pan64 10-26-2020 11:00 AM

Quote:

Originally Posted by SINISTER750 (Post 6178979)
Code:

cat > /etc/profile.d/openjdk.sh << "EOF"
# Begin /etc/profile.d/openjdk.sh

.....
# End /etc/profile.d/openjdk.sh
EOF

These are the contents of /etc/profile.d/openjdk.sh

This should be correct, I double checked what I typed from the BLFS book.

That is definitely wrong. That cannot be correct. This script will create /etc/profile.d/openjdk.sh, so it cannot be the file /etc/profile.d/openjdk.sh.
With other words: when you run this script it will first remove itself and recreate it again. Which is obviously not ok. But I guess the first and last line are not part of the actual script.

most probably pathappend and pathprepend will not work properly on empty/missing directories.

SINISTER750 10-26-2020 12:44 PM

Quote:

Originally Posted by pan64 (Post 6178984)
That is definitely wrong. That cannot be correct. This script will create /etc/profile.d/openjdk.sh, so it cannot be the file /etc/profile.d/openjdk.sh.
With other words: when you run this script it will first remove itself and recreate it again. Which is obviously not ok. But I guess the first and last line are not part of the actual script.

most probably pathappend and pathprepend will not work properly on empty/missing directories.

Yes you are correct, the first and last line are not part of the script but before pathappend and pathprepend variables are already created which should work fine.

pan64 10-26-2020 01:30 PM

Quote:

Originally Posted by SINISTER750 (Post 6179013)
Yes you are correct, the first and last line are not part of the script but before pathappend and pathprepend variables are already created which should work fine.

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.


All times are GMT -5. The time now is 06:21 AM.