Operational Systems & Java
Currently I m running two operating systems on one machine, Windows 2000 and
Windows ME.
Windows ME runs on default, Windows 2000 is on D drive and ME is on C drive. I
tried to add the JDK directory to the classpath but there isn t a autoexec.bat on the D
directory, but there is one for C.
Should I just create a autoexec.bat for D?
Answer: Go to Settings/Control Panel/System/Advanced/Environment Variables...
and
edit your CLASSPATH variable if exists or add a new one.
I need to be able to run a shell script from java, by doing a host call to unix. I am
currently trying Runtime.exec to do this. It says it runs it, but doesn t actually
successfully complete the command (which is a file delete).
I need to be able to run a shell script from java, by doing a host call to unix. I am
currently trying Runtime.exec to do this. It says it runs it, but doesn t actually
successfully complete the command (which is a file delete).
A few questions I have about this:
1. Can I trace it or something to see why it isn t working?
2. How can I get the return code from the shell script?
3. Will the java procedure wait for the shell script to execute, or does
it run a seperate thread concurrently?
Answer: > 1. Can I trace it or something to see why it isn t working?
Runtime.exec() returns a Process object that you can get information from.
If the script is written with sh or some derivate thereof you can do set x in the script
to trace its behaviour. For other scripting languages there is likely a similar
mechanism. To see the trace in your Java program, read from the error or output
streams of the process (Process.getErrorStream() or Process.getOutputStream()).
It s possible that the script is already printing a message to its error stream that you
aren t seeing, indicating why it isn t working.
Answer: > 2. How can I get the return code from the shell script?
Call Process.exitValue().
Answer: > 3. Will the java procedure wait for the shell script to execute, or does it run
a seperate thread concurrently?
The program runs concurrently in a separate *process*, not a thread within the JVM.
To wait for the process to finish, call Process.waitFor().
Are not initializable classes and methods like System.out.println() and
Math.random() "synchronized" ?
Answer: I think they are synchronized. Simple observation: did you ever see once
that printout was broken into two pices by another printouts? I mean for example if
you do:
In 1st thread: System.out.println("1234567890");
And in 2nd thread: System.out.println("something else here");
file:///F|/a_jsite/350_tips/os_win_linux.htm (2 of 8) [2001 07 08 11:24:58]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved