aspose file tools*
The moose likes Beginning Java and the fly likes How to edit security policy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to edit security policy" Watch "How to edit security policy" New topic
Author

How to edit security policy

Hemapriya Sundaram
Greenhorn

Joined: May 16, 2005
Posts: 2
Hi,
I'm a beginner of Java. I executed a shell script from an applet. Its not raising any error while compiling. But while running the applet, the script is not at all executing. While searching the forum, I found that the security policy has to be changed in order to execute a command. What I've to change in the security policy? Where the security policy will be in solaris 8.0? Can I change it as a user? Hope u'll reply me soon. Thanks in advance.


Hemapriya.
Sanju Thomas
Ranch Hand

Joined: Dec 29, 2004
Posts: 243
You can use a tool called 'policytool'. This is GUI tool, you can change the 'java.policy' file according your needs using this tool.

Noramlly java.policy file will be in JAVA_HOME/jre/lib/security directory, you can open this file using policytool and make necessory changes.
Hemapriya Sundaram
Greenhorn

Joined: May 16, 2005
Posts: 2
Hey... I want to graphically represent the virtual memory status of a server. So I'm using applet. But this needs to be dynamic. So I want to get input datas then and there. For this I want to execute the system command. Here is my program :

import java.io.*;
import java.awt.*;
import java.lang.*;
import javax.swing.*;

public class cpu1 extends JApplet
{
public void paint(Graphics g)
{
{
try
{
Runtime r = Runtime.getRuntime();
java.lang.Process P = r.exec("t"); // t is a shell script
}

catch(IOException e)
{
System.err.println(e);
System.exit(1);
}
}

String ch;
int i=1, count=0;

int[] us = new int[30];
int[] us1 = new int[30];

int[] sy = new int[30];
int[] sy1 = new int[30];

int[] id = new int[30];
int[] id1 = new int[30];

String[] myText = new String[5];

{
try
{
FileInputStream fis = new FileInputStream("vmstat.txt");
DataInputStream dis = new DataInputStream(fis);

int j=1;

while ((ch = dis.readLine()) != null)
{
if(i>2)
{
myText = ch.split(" ");

cs[j] = myText[0];
us1[j] = Integer.parseInt(myText[1]);

int count2 = 0;

for(int k=100; k>Integer.parseInt(myText[1]); k--)
count2+=5;

us[j] = count2;

sy1[j] = Integer.parseInt(myText[2]);
int count3 = 0;

for(int k = 100; k > Integer.parseInt(myText[2]);k--)
count3+=3;

sy[j] = count3;

id1[j] = Integer.parseInt(myText[3]);
int count4 = 0;

for(int k = 100; k > Integer.parseInt(myText[3]);k--)
count4+=2;

id[j] = count4;

System.out.println(us[j]);
j++;
count++;
}

i++;
}
}

catch(IOException e)
{
System.out.println(e);
System.exit(0);
}

}
//Title
g.setColor(Color.magenta);
g.setFont(new Font( "Arial", Font.BOLD, 12));
g.drawString("GRAPHICAL REPRESENTATION OF MEMORY USAGE", 300, 30);

g.setColor(Color.blue);

//Co-ordinates of X-axis

g.drawString("Time(Seconds)", 350, 500);

g.setColor(Color.blue);
g.drawLine(100,470,650,470);
g.drawLine(100,470,100,50);

g.setColor(Color.red);
g.fillRect( 600, 50, 10, 10);
g.drawString("cs", 615, 60);

g.setColor(Color.black);
g.fillRect( 600, 70, 10, 10);
g.drawString("us",615, 80);

g.setColor(new Color(125,200,50));
g.fillRect( 600, 90, 10, 10);
g.drawString("sy",615, 100);

g.setColor(new Color(200,20,20));
g.fillRect( 600, 110, 10, 10);
g.drawString("id",615, 120);

g.setColor(Color.black);

for(int c=1; c<=count; c++)
{
if (c>1)
g.drawLine((c-1)*100, us[c-1], c*100, us[c]);

g.fillOval(c*100, us[c], 7, 7);
g.drawString("" + us1[c], c*100, us[c]+20);
}

g.setColor(new Color(125,200,50));

for(int c=1; c<=count; c++)
{
if (c>1)
g.drawLine((c-1)*100, sy[c-1], c*100, sy[c]);

g.fillOval(c*100, sy[c], 7, 7);
g.drawString("" + sy1[c], c*100, sy[c]+20);
}

g.setColor(new Color(200,20,20));

for(int c=1; c<=count; c++)
{
if (c>1)
g.drawLine((c-1)*100, id[c-1], c*100, id[c]);

g.fillOval(c*100, id[c], 7, 7);
g.drawString("" + id1[c], c*100, id[c]+20);
}

}
}

t is a shell script & it contains

vmstat 5 5|awk '{print $19" " $20" " $21" " $22}' > vmstat.txt;

Now tell me, am I proceeding in a right way or not. If not, plz tell me the right way. Or if there is any other way, plz guide me.
 
Don't get me started about those stupid light bulbs.
 
subject: How to edit security policy