Problem in loading a text file to java aglet application.

R

Ravikumar

Hi,

I am writing a java aglet application to do snmp operation. I tried
with Aglet2.0.2 with windows XP OS. My application will load a text
file(MIB file) from the path which I have specified and parse the
file. Also load the content in memory interms of MIB objects.

What I done is, I have copied the RFC1213-MIB file to the directory
C:\Ravikumar\SoftWare\Aglets\Aglets2.0.2\public and load the same.
The below method call will do as

tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
RFC1213-MIB");

It loads RFC1213-MIB file from "C:/Ravikumar/SoftWare/Aglets/
Aglets2.0.2/public and parse the content. But while loading this file,
I have got the following exception

Exception : java.io.FileNotFoundException: Could not find the file :
C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/RFC1213-MIB

ERROR

I can't able to load this file. But when I try with as stand alone
java application it works fine.

My question is, how to load a text file to a java application in
Aglets.

Please help to resolve this problem.

Thanks in Advance.

Cheers
Ravikumar

My code snippet is


import com.ibm.aglet.*;
import com.ibm.aglets.*;
import com.ibm.aglet.event.*;
import com.ibm.aglet.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import com.adventnet.snmp.ui.*;
import com.adventnet.snmp.mibs.*;
import com.adventnet.snmp.beans.*;
import java.io.*;
import java.net.*;
public class largetable extends Aglet
{

JFrame f = new JFrame("SNMP Table");
SnmpTablePanel tablepanel ;
JScrollPane scrollpane;


public void run()
{
tablepanel = new SnmpTablePanel();
tablepanel.setTargetHost("proto-test3");
tablepanel.setCommunity("public");


try{

tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
RFC1213-MIB");
tablepanel.setTableOID("ifTable");

}catch(Exception e)
{
System.out.println("ERROR");
}



scrollpane = new JScrollPane(tablepanel);
f.add(scrollpane);
f.setSize(500,500);
f.show();

}

}
 
A

Andrew Thompson

Ravikumar wrote:
..
I am writing a java aglet application

As I understand it, an aglet is an AGile appLET,
so the term 'aglet application' is wrong, it is
simply an 'Aglet'. Applets are quite distinct (in Java
terminology) from applications, and it is best not to
mix the terms. Applets normally operate within a
security sandbox that prevents operations such
as loading files off the local file system.
...
tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
RFC1213-MIB");

And that is a file.
It loads RFC1213-MIB file from "C:/Ravikumar/SoftWare/Aglets/
Aglets2.0.2/public and parse the content. But while loading this file,
I have got the following exception

Exception : java.io.FileNotFoundException: Could not find the file :
C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/RFC1213-MIB

ERROR

How do you know it is an FNFE? The code below..
try{

tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
RFC1213-MIB");
tablepanel.setTableOID("ifTable");

}catch(Exception e)
{
System.out.println("ERROR");
}
}

<http://snmp.adventnet.com/help/snmp...SnmpTablePanel.html#loadMibs(java.lang.String
)>
..might throw FNFE, IOException, or a MibException.

It seems odd that list does not include any security
exceptions, which is what I would expect a sandboxed
applet to throw if it attempted file access.

So, is this code actually operating as an applet?
Is it working in a browser?
(It seems so to me, but tonight is the first time I
ever bothered checking the meaning of 'Aglet')

If so, you might look into passing the Applet as a param
to the constructor of the panel mentioned/linked above,
and the panel will attempt to fetch the resource via URL.

HTH

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 
R

Ravikumar

Hi Andrew,

Thanks for your response.

Sorry I make a confusion about using Aglet application for Aglet. I
will correct myself hereafter.

This application is SWING application and not a applet. This is
working fine for me as standalone java application.

Herewith I have attached the code.

import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import com.adventnet.snmp.ui.*;
import com.adventnet.snmp.mibs.*;
import com.adventnet.snmp.beans.*;
import java.io.*;
import java.net.*;
public class largetable1 extends JFrame
{
public static void main(String args[])
{
JFrame f = new JFrame("SNMP Table");
JScrollPane scrollpane;
SnmpTablePanel tablepanel = new SnmpTablePanel();
tablepanel.setTargetHost("localhost");
tablepanel.setCommunity("public");
try{
tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/
public/RFC1213-MIB");
tablepanel.setTableOID("ifTable");

}catch(Exception e)
{
System.out.println("ERROR");
}
scrollpane = new JScrollPane(tablepanel);
f.add(scrollpane);
f.setSize(500,500);
f.show();

}

}


Please help me out to resolve this issue in Aglet.

Look forward to hear from you.

Cheers
Ravikumar
 
A

Andrew Thompson

Ravikumar wrote:
..
Thanks for your response.

Your future lack of top-posting, will be thanks enough.
Sorry I make a confusion about using Aglet application for Aglet. I
will correct myself hereafter.

This application is SWING ..

That is 'Swing' - it is not an acronym, and there
is no need to SHOUT.
..application and not a applet.

I am confused that you would 'emphasize' Swing before
that statement, since (J)Applets use Swing.
..This is
working fine for me as standalone java application.

Herewith I have attached the code.

Why? You did that already, and I have no intention
of installing all the crud needed to compile and run
this example. But I think you missed the point I
thought I'd discovered earlier, that an Aglet is *really*
an Applet.

No, wait a second.. this source is different to the
earlier source, most importantly in this line.
public class largetable1 extends JFrame

I note that line earlier was..
public class largetable extends Aglet
..in the original source posted.

Are you indicating it is the JFrame based code
that works OK?

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
 
R

Ravikumar

Hi,


The first one which I tried with Aglet.

Second one will be standalone Java application.
Are you indicating it is the JFrame based code
that works OK?

Yes. JFrame code works fine.

Please if it possible explain with simple program as how to load a
text file in Aglet.

My problem is I am not able to load this file.

Cheers
Ravikumar
 
O

Oliver Wong

Ravikumar said:
The first one which I tried with Aglet.

Second one will be standalone Java application.

that works OK?

Yes. JFrame code works fine.

Please if it possible explain with simple program as how to load a
text file in Aglet.

My problem is I am not able to load this file.

My guess is it's a security issue.

http://www.trl.ibm.com/aglets/spec10.htm
<quote>
A user can specify specific authorizations for trusted and untrusted
aglets that govern read/write access to files and libraries, object
instantiation, and window access and warning. These security options are
defined for each aglet security category (trusted and untrusted) and are
stored in the files

* $HOME/.aglets/security/trusted (or $JAVA_HOME if there is no $HOME)
and
* $HOME/.aglets/security/untrusted (or $JAVA_HOME if there is no
$HOME).
</quote>

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top