LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This 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


Reply
  Search this Thread
Old 10-26-2020, 01:47 PM   #16
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by pan64 View Post
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
 
Old 10-26-2020, 01:50 PM   #17
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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
 
Old 10-26-2020, 01:54 PM   #18
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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?
 
Old 10-26-2020, 01:56 PM   #19
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you do not need gui.
Code:
bash -xv  /etc/profile.d/openjdk.sh >/tmp/file 2>&1
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).
 
Old 10-26-2020, 03:02 PM   #20
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
you do not need gui.
Code:
bash -xv  /etc/profile.d/openjdk.sh >/tmp/file 2>&1
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.
 
Old 10-26-2020, 03:25 PM   #21
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by SINISTER750 View Post
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
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.
 
Old 10-27-2020, 02:38 AM   #22
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
there is an error in this line (several times).
Code:
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
this find command should have been executed and returned a list of directories, and in the next line
Code:
pathappend find '${AUTO_CLASSPATH_DIR}' -type d '2>/dev/null` CLASSPATH
instead of the command itself the directory name should be used, like:
Code:
pathappend /usr/share/java/dir1 CLASSPATH
pathappend /usr/share/java/dir2/dir3 CLASSPATH
....
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???

Last edited by pan64; 10-27-2020 at 02:55 AM.
 
1 members found this post helpful.
Old 10-27-2020, 04:28 AM   #23
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
there is an error in this line (several times).
Code:
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
this find command should have been executed and returned a list of directories, and in the next line
Code:
pathappend find '${AUTO_CLASSPATH_DIR}' -type d '2>/dev/null` CLASSPATH
instead of the command itself the directory name should be used, like:
Code:
pathappend /usr/share/java/dir1 CLASSPATH
pathappend /usr/share/java/dir2/dir3 CLASSPATH
....
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
 
Old 10-27-2020, 04:31 AM   #24
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by SINISTER750 View Post
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
Any suggestions please!
 
Old 10-27-2020, 04:40 AM   #25
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Quote:
Originally Posted by SINISTER750 View Post
Well, I checked the lines where the errors were found and they are no different than the output.
I don't understand it
Quote:
Originally Posted by SINISTER750 View Post
I'm using bash 5.0 as it is needed for BLFS 8.4
bash 5.0 should be ok.
I have no any idea why was that backtick not handled properly. Maybe you can replace it: $(find ..... 2>/dev/null)
 
Old 10-27-2020, 09:22 AM   #26
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I don't understand it

bash 5.0 should be ok.
I have no any idea why was that backtick not handled properly. Maybe you can replace it: $(find ..... 2>/dev/null)
Someone suggested to me that the variable export syntax is

export PATHVARIABLE=value
(Not)
export $PATHVARIABLE=value

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.
 
Old 10-27-2020, 09:39 AM   #27
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
yes, in general export PATHVARIABLE=value should be used, but this is a special case and export $PATHVARIABLE=value is correct.
 
Old 10-27-2020, 09:55 AM   #28
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
yes, in general export PATHVARIABLE=value should be used, but this is a special case and export $PATHVARIABLE=value is correct.
Could there be something wrong in the bash shell startup files when I created them? Because the Java configuration script needs it.

Last edited by SINISTER750; 10-27-2020 at 09:56 AM.
 
Old 10-27-2020, 10:03 AM   #29
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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
 
1 members found this post helpful.
Old 10-27-2020, 10:09 AM   #30
SINISTER750
Member
 
Registered: Sep 2020
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Java Woes: A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available ... chytraeus Slackware 10 11-27-2010 10:04 AM
Yet another java classpath question --- java.lang.NoClassDefFoundError Jama raequin Programming 1 12-29-2009 01:04 PM
How to set the CLASSPATH environment variable Rodotheos Programming 3 06-20-2005 04:30 AM
How to set PATH and CLASSPATH environment variables bronko Linux - Newbie 2 12-20-2003 11:13 AM
ClASSPATH variable for Java oulevon Linux - General 1 02-28-2001 08:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 05:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration