Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Java binary locator, bash srcipt< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 18 2006,15:02 QUOTE

I'm planning a bash script for DSL that checks if java binary is located somewhere in the filesystem. If found then make an alias like this: alias java="/opt/javasomething/bin/java" or make a symlink o to $PATH or even better and easier: scrpt itself is in $PATH and if no java is installed it asks if user wants to install java. If yes then it installs java and then executes the original command. Ofcourse if java executable is already found then just run java executable with arguments.

Why this?
Because it is very easy to run java programs in linux only if java is installed. Just as simple as: $ java -jar your_program.jar
And with this script people new to Linux can easily download Java programs and run them in DSL.

I'd like to have some tips about  how this script should look for the java executable.
Also opinions about how this script should act are welcome. =)


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Oct. 18 2006,16:57 QUOTE

Look at /usr/local/bin/links for a simple way to do part of it in lua.
This script does not handle files not in PATH, however.

I'm not sure how it would be done in Lua, but something like this might work in Bash:
(untested)
Code Sample
#!/bin/sh
if which java &>/dev/null; then
 JAVA=`which java`
elif [ -x "/opt/javasomething/bin/java" ]; then
 JAVA="/opt/javasomething/bin/java"
else
  echo "retrieving jre1_5_0.uci ..."
  mydsl-load jre1_5_0.uci uci && JAVA="/opt/javasomething/bin/java"
fi

if [ -x "${JAVA}" ]; then
 exec ${JAVA} "$@"
else
 echo "error!"
 exit 1
fi

Use this in place of the java command...but don't name it "java" unless it's not in your PATH.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 18 2006,17:29 QUOTE

Many thanks. I'll see what I can do. :)

--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Oct. 18 2006,18:38 QUOTE

Don't forget CLASSPATH and some Java stuff wants JAVA_HOME.
Back to top
Profile PM WEB 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 18 2006,19:00 QUOTE

I managed to find java binary location like this:
Code Sample
JAVAEXEC=`sudo find /* | grep "/bin/java\$" 2> /dev/null `; echo $JAVAEXEC


At least it works with DSL. =D And that is what I actually need.

Next thing is to add that into script which checks if it is an executable:
Code Sample
if [ -x $JAVAEXEC ]

But I think I should also make it to check if it is a symlink...


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
8 replies since Oct. 18 2006,15:02 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: Java binary locator

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code