Link to home
Start Free TrialLog in
Avatar of ICPooreman
ICPooreman

asked on

edit CLASSPATH in .bashrc from schell script

I'm writing a shell script in which I want to append variable to my classpath in my .bashrc file.  Is there an easy way to do this?
ASKER CERTIFIED SOLUTION
Avatar of cjjclifford
cjjclifford

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ICPooreman
ICPooreman

ASKER

The first part changes the variable in my script but my commands in the script later are still using the original set in the .bashrc file.  If I do an echo on CLASSPATH the value will have changed however, it doesn't appear to be effecting the later commands in the script.

I'm unfamiliar with what the second option is supposed to be doing but it didn't work either.  It closed down my shell and nothing happened when I ran it.
Do you have the "export" in place? without the "export" settings to the variable are only for the shell itself, not children - the export makes the change for the current shell's children processes (i.e. the "java" command).

The second approach would exit the command shell if there's an exit...

you can also specify classpath variables for Java, e.g.

#!/bin/bash

export MY_CLASSPATH=$CLASSPATH:my.jar

java -cp $MY_CLASSPATH my.org.HelloWorld

Cheers,
C.

You're right it was a typo on my side, Sorry thanks for the help
Glad to be of help!