Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Problem in loading a text file to java aglet application.

Thread view: 
Ravikumar - 10 Apr 2007 13:27 GMT
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();

}

}
Andrew Thompson - 10 Apr 2007 14:19 GMT
..
>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,
[quoted text clipped - 4 lines]
>
>ERROR

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

>try{
>
[quoted text clipped - 6 lines]
>  System.out.println("ERROR");
> }
}

<http://snmp.adventnet.com/help/snmpapi/snmpv3/javadocs/com/adventnet/snmp/ui/Snm
pTablePanel.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

Signature

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

Andrew Thompson - 10 Apr 2007 14:22 GMT
...
>>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.

Signature

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

Ravikumar - 11 Apr 2007 11:45 GMT
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

> ..
>
[quoted text clipped - 11 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
Andrew Thompson - 11 Apr 2007 13:15 GMT
..
> 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?

Signature

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

Ravikumar - 11 Apr 2007 16:30 GMT
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

> .
>
[quoted text clipped - 43 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
Andrew Thompson - 11 Apr 2007 17:01 GMT
(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.

Signature

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

Oliver Wong - 11 Apr 2007 17:57 GMT
> The first one which I tried with Aglet.
>
[quoted text clipped - 9 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.