Problem in loading a text file to java aglet application.

Discussion in 'Java' started by Ravikumar, Apr 10, 2007.

  1. Ravikumar

    Ravikumar Guest

    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();

    }

    }
     
    Ravikumar, Apr 10, 2007
    #1
    1. Advertising

  2. 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
     
    Andrew Thompson, Apr 10, 2007
    #2
    1. Advertising

  3. Andrew Thompson, Apr 10, 2007
    #3
  4. Ravikumar

    Ravikumar Guest

    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
     
    Ravikumar, Apr 11, 2007
    #4
  5. 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.aspx/java-general/200704/1
     
    Andrew Thompson, Apr 11, 2007
    #5
  6. Ravikumar

    Ravikumar Guest

    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
     
    Ravikumar, Apr 11, 2007
    #6
  7. Andrew Thompson, Apr 11, 2007
    #7
  8. Ravikumar

    Oliver Wong Guest

    "Ravikumar" <> wrote in message
    news:...
    >
    > 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
     
    Oliver Wong, Apr 11, 2007
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    Mobile Agent Java Aglet

    Guest, May 1, 2004, in forum: Java
    Replies:
    0
    Views:
    960
    Guest
    May 1, 2004
  2. David Segall
    Replies:
    2
    Views:
    452
    Thomas Kellerer
    Jan 2, 2007
  3. computerman

    aglet problem

    computerman, Feb 11, 2007, in forum: Java
    Replies:
    0
    Views:
    362
    computerman
    Feb 11, 2007
  4. moneybhai

    getting mac address through aglet

    moneybhai, Aug 16, 2009, in forum: Java
    Replies:
    13
    Views:
    826
    Arne Vajhøj
    Aug 18, 2009
  5. moneybhai

    aglet

    moneybhai, Aug 16, 2009, in forum: Java
    Replies:
    3
    Views:
    429
    Martin Gregorie
    Aug 17, 2009
Loading...

Share This Page