Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Java in General and the fly likes calling Unix script from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "calling Unix script from Java" Watch "calling Unix script from Java" New topic

calling Unix script from Java

Sandeep Advani
Ranch Hand

Joined: Mar 11, 2004
Posts: 78

Code snippet is -

I get this exception...

Start compiling ....
Command is source TestClient
Check point 1
Caught an IO exception source: not found
at java.lang.UNIXProcess.<init>(
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at CompileJava.doWork(
at CompileJava.main(
Exception in thread "main" java.lang.NullPointerException
at CompileJava.doWork(
at CompileJava.main(

Says source not found but the command runs well when I run this from
the shell prompt.

Thanks again
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
"source" is a C-shell command (ok, maybe other shells that I'm not familiar with too). Under Unix Java will call the native fork()/exec() of the platform. Under Solaris this is "/bin/sh". Under Linux I think it is "/bin/ksh" but don't hold me to that. Therefore, you will want to do something like:

<a href="" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Have you tried LearnNowOnline?
subject: calling Unix script from Java