i'm new to java. I've been learning applets and all and i've been trying to make a simple program that uses the system class to get the properties of the machine. In simple words,i'm trying to output the windows name,its version and the architecture. I tried doing something. When i tried running it through the appletviewer,it runs but when i try running it on a server it shows some errors.What could possibly be wrong with the code? Please help,since i'm new to this. Heres the link to the applet.
http://ashish.club-tec.co.il/sysf.html
and heres the code
import java.applet.*;
import java.awt.*;
public class sysf extends Applet
{
Label l1,l2;
String p;
public void init()
{
l1=new Label("Operating system is ");
l2=new Label("");
add(l2);
add("Center",l1);
p=System.getProperty("user.name");
l2.setText("Hi "+p+",your system info is as follows");
p= System.getProperty("os.name");
l1.setText(l1.getText()+p);
p=System.getProperty("os.version");
p=" version "+p+" ";
l1.setText(l1.getText()+p);
p=System.getProperty("os.arch");
p=" and architecture is "+p+" ";
l1.setText(l1.getText()+p);
}
}
Thanks!
You'll need to set up a custom applet security policy. Here is a tutorial that covers that including setting a policy to enable
user.home
to be read:http://geosim.cs.vt.edu/Java/MigModel/help/Policies.html
This sort of pain is mostly specific to Applets. Java is extremely restrictive with Applets for security reasons. If you want to learn Java, a better approach would be to learn desktop JSE or start working with servlets.