• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I execute "ipconfig /all" from applet?

 
Neir Kate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm still new in java applet, so there are some problems that I cannot solve, and I need help from the masters here

I'm trying to execute "ipconfig /all" (In Windows of course) using the Java code, as follow (InetAddressApplet.java):

public final static String getMacAddress() {
String macAddress ="";
bla...bla...
Process p = Runtime.getRuntime().exec("ipconfig /all");
bla...bla..bla
return macAddress;
}
and in the jsp, I have also include the applet:

<applet code="InetAddressApplet.class" width="0" height="0" name="InetAddressApplet"></applet>

then, I'm trying to get the MacAddress by parsing the value I get from "ipconfig /all" by using:
alert(document.applets['InetAddressApplet'].getMacAddress());

I also have editted the java.policy in
C:\Program Files\Java\jre1.5.0_11\lib\security
and
C:\Program Files\Java\jdk1.5.0_11\jre\lib\security

adding the following lines :

grant codeBase "http://192.168.1.46:7080/emf/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "<<ALL FILES>>", "read, write, delete, execute";
};

but I still get the error message :

access denied (java.io.FilePermission <<ALL FILES>> execute)

after I print the trace, it stated that the access is denied in the line that's calling "ipconfig /all", how can I solve this problem? Are there any steps that I missed?

Thanks in advance, and sorry for my poor english
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which URL are you using to access the applet?

Is the JRE in "C:\Program Files\Java\jre1.5.0_11" the one being used by the Java Plugin?
 
Neir Kate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm accessing http://192.168.1.46:7080/emf/index.jsp where "192.168.1.46" is my localhost. Oh yeah, your question make my test my code using Internet Explorer and it works, but I still get the "access denied" using mozilla firefox and when I typed in, "about lugins", it said that the Java version it is using is:
Java(TM) 2 Platform Standard Edition 5.0 U11
File name: NPJava11.dll
Java Plug-in 1.5.0_11 for Netscape Navigator (DLL Helper)

I wonder what is wrong? Is it possible that the mozilla browser using different version of jre? and is there any other way I can check this?

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic