Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem in loading a text file to java aglet application.

Reply
Thread Tools

Problem in loading a text file to java aglet application.

 
 
Ravikumar
Guest
Posts: n/a
 
      04-10-2007
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();

}

}

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      04-10-2007
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/snmpa...va.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.asp...neral/200704/1

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      04-10-2007
Andrew Thompson wrote:
...
>>tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
>>RFC1213-MIB");

>
>And that is a file.


Oops! That is a String that is a representation of
a file path and name as it might appear in a Windows
environment, as opposed to a file, or a (java.io.)File.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200704/1

 
Reply With Quote
 
Ravikumar
Guest
Posts: n/a
 
      04-11-2007
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

On Apr 10, 6:22 pm, "Andrew Thompson" <u32984@uwe> wrote:
> Andrew Thompson wrote:
>
> ..
>
> >>tablepanel.loadMibs("C:/Ravikumar/SoftWare/Aglets/Aglets2.0.2/public/
> >>RFC1213-MIB");

>
> >And that is a file.

>
> Oops! That is a String that is a representation of
> a file path and name as it might appear in a Windows
> environment, as opposed to a file, or a (java.io.)File.
>
> --
> Andrew Thompsonhttp://www.athompson.info/andrew/
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      04-11-2007
Ravikumar wrote:
..
> Thanks for your response.


Your future lack of top-posting, will be thanks enough.
<http://www.physci.org/codes/javafaq.html#toppost>

> 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.asp...neral/200704/1

 
Reply With Quote
 
Ravikumar
Guest
Posts: n/a
 
      04-11-2007

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



On Apr 11, 5:15 pm, "Andrew Thompson" <u32984@uwe> wrote:
> Ravikumar wrote:
>
> .
>
> > Thanks for your response.

>
> Your future lack of top-posting, will be thanks enough.
> <http://www.physci.org/codes/javafaq.html#toppost>
>
> > 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 Thompsonhttp://www.athompson.info/andrew/
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      04-11-2007
Ravikumar wrote:

(top-posted reply)
>Hi,


From earlier..
"Your future lack of top-posting, will be thanks enough.
<http://www.physci.org/codes/javafaq.html#toppost>"

Your current top-posting makes me think you do
not take my time or help seriously.

Bye.

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200704/1

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      04-11-2007
"Ravikumar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>
> 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.


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting mac address through aglet moneybhai Java 13 08-17-2009 11:06 PM
aglet moneybhai Java 3 08-17-2009 08:37 AM
aglet problem computerman Java 0 02-11-2007 03:53 AM
[OT] Is loading the second Java application faster than loading the first? David Segall Java 2 01-02-2007 04:41 PM
Mobile Agent Java Aglet Java 0 05-01-2004 04:42 PM



Advertisments