N
Nagesh
I want to know user home directory when i run through java applet. I
could not success through System.getProperty("user.home") as it gave me
security exception. Then i tried the following way which simply exec
the commands "echo %HOMEDRIVE%%HOMEPATH%" for windows and for linux
"echo $HOME". But this also fails as it is giving me the exception
java.io.IOException: CreateProcess: echo %HOMEDRIVE%%HOMEPATH% error=2
and java.io.IOException: CreateProcess: echo %HOMEDRIVE%%HOMEPATH%
error=2. what these errors mean?
is there any other way of knowing home directory in platform neutral
way?
I tried the following souce code.
import java.applet.* ;
import java.io.*;
public class execOutput extends Applet{
public void init(){
}
public void start(){
String envoutput=readenv();
}
String readenv(){
String env="echo %HOMEDRIVE%%HOMEPATH%";
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec(env);
// get its output (your input) stream
DataInputStream ls_in = new DataInputStream(
ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null) {
return ls_str;
}
} catch (IOException e) {
System.out.println("Exception in
environmental output"+e);
}
} catch (IOException e1) {
System.out.println("Exception in
environmental output"+e1);
env="echo $HOME";
}
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec(env);
// get its output (your input) stream
DataInputStream ls_in = new DataInputStream(
ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null) {
return ls_str;
}
} catch (IOException e) {
System.out.println("Exception in
environmental output");
}
} catch (IOException e1) {
System.out.println("Exception in
environmental output"+e1);
env="echo $HOME";
}
return "not found";
}
}
thanks
Nagesh
could not success through System.getProperty("user.home") as it gave me
security exception. Then i tried the following way which simply exec
the commands "echo %HOMEDRIVE%%HOMEPATH%" for windows and for linux
"echo $HOME". But this also fails as it is giving me the exception
java.io.IOException: CreateProcess: echo %HOMEDRIVE%%HOMEPATH% error=2
and java.io.IOException: CreateProcess: echo %HOMEDRIVE%%HOMEPATH%
error=2. what these errors mean?
is there any other way of knowing home directory in platform neutral
way?
I tried the following souce code.
import java.applet.* ;
import java.io.*;
public class execOutput extends Applet{
public void init(){
}
public void start(){
String envoutput=readenv();
}
String readenv(){
String env="echo %HOMEDRIVE%%HOMEPATH%";
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec(env);
// get its output (your input) stream
DataInputStream ls_in = new DataInputStream(
ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null) {
return ls_str;
}
} catch (IOException e) {
System.out.println("Exception in
environmental output"+e);
}
} catch (IOException e1) {
System.out.println("Exception in
environmental output"+e1);
env="echo $HOME";
}
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec(env);
// get its output (your input) stream
DataInputStream ls_in = new DataInputStream(
ls_proc.getInputStream());
try {
while ((ls_str = ls_in.readLine()) != null) {
return ls_str;
}
} catch (IOException e) {
System.out.println("Exception in
environmental output");
}
} catch (IOException e1) {
System.out.println("Exception in
environmental output"+e1);
env="echo $HOME";
}
return "not found";
}
}
thanks
Nagesh