Getting the Java Version I want in a SunOS account [closed] - sunos

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have an account on a Unix server. I can't get it to point to the version of Java I want when I am in BASH.
The version of Unix is:
SunOS 5.10 Generic January 2005
This is what I have in my .profile:
#====================================================================
# set the environment
#====================================================================
ANT_HOME=/apps1/apache-ant-1.8.4
export ANT_HOME
# $PATH:/user1/acme21 needs to be included to make anything work
PATH=.:/usr/jdk/instances/jdk1.6.0_24:$ANT_HOME/bin:$PATH:/user1/acme21
export PATH
JAVA_HOME=/usr/jdk/instances/jdk1.6.0_24
export JAVA_HOME
CLASSPATH=.:/user1/sterus01/TestProgramsLib/mail.jar:/user1/sterus01/TestProgramsLib/activation.jar:/user1/sterus01/TestProgramsLib/log4j-1.2.16.jar:/user1/sterus01/TestProgramsLib/mail.jar:ojdbc14.jar
export CLASSPATH
env | grep DIS
# Use the bash shell, get many conveniences
bash
When I run echo $JAVA_HOME and echo $PATH I get
bash-3.00$ echo $JAVA_HOME
/usr/jdk/instances/jdk1.6.0_24
bash-3.00$
and
bash-3.00$ echo $PATH
.:/usr/jdk/instances/jdk1.6.0_24:/apps1/apache-ant-1.8.4/bin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/etc:/usr/ucb:/usr/local/sudo:/usr/local/sbin:/user1/acme21
bash-3.00$
Yet "which javac" reveals:
bash-3.00$ which javac
/usr/bin/javac
bash-3.00$
and "which java" reveals:
bash-3.00$ which java
/usr/bin/java
bash-3.00$
Is there anything I can do to get it to point to the Java version I specified in my .profile file?
Thanks in advance
Happy Holidays
Steve

Are you sure your java and javac executables are in /usr/jdk/instances/jdk1.6.0_24 ? Perhaps they are in /usr/jdk/instances/jdk1.6.0_24/bin/.

I suspect this:
PATH=.:/usr/jdk/instances/jdk1.6.0_24
isn't right, and you need instead
PATH=.:/usr/jdk/instances/jdk1.6.0_24/bin
to pick up the binary directory within that Java installation.
p.s. I wouldn't put the current directory (.) in your PATH. Otherwise someone can substitute a trojan-like program (e.g. a substitute for ls) in a directory. You'll pick that up when you cd into the containing directory and type ls (there's an entertaining story relating to this in the Unix Power Tools book)

Related

How to make a command to launch a bash-script in mac terminal? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Basically, I want to be able to have a command for my command-line "Net", kinda like the "Python" command used to start python.
So I'd like to have a command like "Net" or something to start my bash-script, but I don't want to go into my .bash_profile and make an alias, I want it to be created automatically if you just run a script.
How would this be done?
It seems like you're looking for the install command...
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/install.1.html
install -m 755 ./my-bash-script.sh /bin/net
Just be sure use a directory that is in your $PATH and that you don't already have an executable file in your $PATH that is using the name of the command you plan to use. 'net' is an actual command used on linux systems, but I'm not sure about the Mac.
If you add it to your bash script, you might want to add some sanity checks...
#! /bin/bash
...
...
[[ ! -f /bin/$(basename $0) ]] && install -m 755 $0 /bin/$(basename $0)

How to change the terminal prompt to just current directory? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am using a Macbook Pro, and I wanted to change it to the current directory and a dollar sign prompt in Terminal. I've already looked at these resources to try and solve this issue.
I tried modifying the ~/.bashrc file and saving it but it did not seem to work.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PS1="\W$ ”
The last line is what I added to change the prompt.
This should be done in .bash_profile, not .bashrc.
nano ~/.bash_profile
Add a line containing this:
export PS1="\W\$ "
.bashrc is ONLY excuted when starting a sub-shell. bash login shell uses the following initialization scripts:
.bash_profile
.bash_login
.profile
You need to escape the dollar sign. Like this:
$ PS1="\W\$ "
~$ cd tmp
/Users/philip/tmp
tmp$
And once you change your .bashrc you either need to logout/back-in or . ~/.bashrc to re source it.
I would humbly recommend not doing this. Having a full path is very useful as 'tmp' directories could be anywhere. Consider using "\w" which does relative path (ie. uses ~ to represent HOME)

What is a good default PATH to use if none is defined by the environment? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm making a small shell for a school project and I was searching about default PATHs. Say there is no PATH in the global environ variable, the various shells I tested always managed to search some default paths (sometimes unknown) to find the executable to run [ls is chosen as an example]:
Bash Shell behaves like so:
dflt-zsh > env -i bash
bash-3.2$ echo $PATH
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
bash-3.2$ ls
Makefile shell.c src includes
bash-3.2$ export PATH=
bash-3.2$ ls
bash: ls: No such file or directory
C Shell seems to be lost when no PATH is defined but found the ls executable nonetheless:
dflt-zsh > env -i csh
% echo $PATH
PATH: Undefined variable.
% ls
Makefile shell.c src includes
Z Shell has the most elements in $PATH but it may be reading some of my default zsh configuration files (not very trustworthy example):
dflt-zsh > env -i zsh
achedeuzot% echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin
achedeuzot% ls
Makefile shell.c src includes
achedeuzot% PATH=
achedeuzot% ls
zsh: command not found: ls
TC Shell behaves as C shell.
dflt-zsh > env -i tcsh
> echo $PATH
PATH: Undefined variable.
> ls
Makefile shell.c src includes
What is a good "default PATH" to search even if none is set ? I was going for something along the lines of PATH=/usr/local/bin:/bin:/usr/bin:.
How can I choose which directories to include by default ? Are there some crucial directories to search ? Main question: Is it "choose what you like" or are there any basic rules that all the shells follow ?
Thanks for your help !
There is no universal solution. On some systems, /bin is a symlink to /usr/bin, so adding just /usr/bin to PATH will get you most of the programs. Adding /usr/gnu/bin or /usr/local/bin is optional; not all systems have either or both of those. Sometimes people add /sbin and /usr/sbin. The list of variations goes on. The basic, minimal PATH setting is usually:
/bin:/usr/bin
Anything extra is precisely that — extra. (And, as noted, on some systems, that is not a minimal PATH.)

Using the unzip command in SSH with Mac Terminal not working [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I logging into my server from the Mac Terminal Bash Shell and the unzip command is not working I keep getting the following message:
bash: unzip: command not found
Can I unzip a file via SSH from Mac Terminal?
The program unzip should be in /usr/bin:
$ type unzip
unzip is /usr/bin/unzip
Worst case, you can always just "ask for it by name":
$ /usr/bin/unzip foo.zip
You should check your PATH variable, as it should normally include /usr/bin:
$ echo $PATH
$ PATH=/bin:/usr/bin:$PATH
$ export PATH
Make sure you have selected a login shell for your Terminal. This will set a good value for the PATH variable when the shell starts.

All commands are not working on mac os x lion [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am facing a problem, i can't run even a single command on my mac osx lion terminal, even "ls" command, when i print $PATH variable, found
My-Mac:/ Mac$ echo $PATH
/usr/local/git/bin
Please help me if you have guys have any solution for that.
thanks
You should probably ask this question on superuser.stackexchange.com (for "power user"-type questions; instead of here, which is meant for programming questions).
But I'll help you out a little bit: beyond the .tcshrc file you should also have for your home directory, also check to see if you have any files at /usr/share/tcsh/examples. That is where the "global" tcsh settings (including PATH) should be found.
If you don't have a .tcshrc file... create one in TextEdit and add something like:
set path = ( \
~/bin \
/usr/local/bin /usr/bin /bin \
/usr/local/sbin /usr/sbin /sbin \
)
to it.
Oh yeah, lastly... I'm assuming you're using tcsh since that's the usual Macintosh shell. You can make sure by typing in echo $SHELL at the command line.

Resources