Security restrictions , how to read access a txt file supplied in a jar

I had written a simple application which uses file handling to display random line from a file on a swing window
but I do not know how to give my web application permission to access a file
when I set security permission to all, then error says the application cannot load because the code require unrestricted acess to system resources and is unsigned, I don't know how to get that certificate and I am only doing it for learning purposes.
when I remove security permissions then it says
access denied java.io.FilePermissions geekjoskes.txt readPlease help
I locally signed the jar file, and give my jnlp fiel all permissions, worked fine in my system but when I access same file from local lan it sho errors ,
please help, I have my txt file stored in my jar file with main class
the whole jnlp file is
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for geek jokes -->     
<jnlp spec="1.0+"
       codebase="http://localhost/javasoft/webstart/"
      href="geekjokes.jnlp">
   <information>
      <title>Geek Jokes</title>
      <vendor>Vaibhav Mishra</vendor>
      <description>Geeky jokes</description>
      <homepage href="http://scjpbeginner.blogspot.com"/>
      <description kind="short">shows random jokes</description>
      <offline-allowed/>
   </information>
   <resources>    
        <jar href="GeekJokes0.1.jar"/>  
     <j2se version="1.6+"
           href="http://java.sun.com/products/autodl/j2se"/>
     <icon href="geekjokes.gif"/>
   <icon kind="splash" href = "geekjokes.gif"/>
   </resources>
   <security>
      <all-permissions/>
   </security>
   <offline-allowed/>  
   <application-desc main-class="GeekJokes"/>
</jnlp>Edited by: 76jsr on Aug 7, 2008 3:45 PM
Edited by: 76jsr on Aug 7, 2008 3:49 PM

>
I am extremely thankful to you and finally my first little app is working thanks to you,
here is it's link
[http://profile.iiita.ac.in/IIT2006117/javasoft/webstart/geekjokes/geekjokes.jnlp|http://profile.iiita.ac.in/IIT2006117/javasoft/webstart/geekjokes/geekjokes.jnlp] >
I am glad you got it working! But that launch file is still slightly invalid.
Here is a corrected, and slightly optimized (you can leave the prefix off the href, if it is the same as the codebase), version of it.
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for GeekJokes 0.3 app -->
<jnlp spec="1.0+"
      codebase="http://profile.iiita.ac.in/IIT2006117/javasoft/webstart/geekjokes"
      href="geekjokes.jnlp">
   <information>
      <title>GeekJokes App</title>
      <vendor>Vaibhav Mishra</vendor>
      <homepage href="http://scjpbeginner.blogspot.com"/>
      <description>Geeky Jokes</description>
      <description kind="short">Cshows random jokes</description>
      <offline-allowed/>
   </information>
   <resources>
       <j2se version="1.6+"
           href="http://java.sun.com/products/autodl/j2se"/>
       <jar href="GeekJokes0.3.jar"/>
   </resources>
   <application-desc main-class="Process"/>
</jnlp>Very 'Geeky', BTW. ;-)
Another few things I noted when I looked at it.
1) There is a stray thread going after the JOptionPane is dismissed. The VM does not end, and the console (if you have it configured to pop-up for JWS apps.) stays on-screen.
2) If all the jokes are prefixed by '* ' I would recommend removing it from every line of the source file and either re-adding it at runtime, or (preferably) not adding it at all (since it is redundant).
3) Reconfigure the app. into a loop, and offer the user a JOptionPane with "Another Joke"/"End" instead of "OK".
4) You can always remove that debugging line I inserted in the code to show the path to the Jar - it was just intended as a 'sanity check' during testing.
5) Why is it Java 1.6+? JOptionPane was introduced in Java 1.2 with the first Swing implementations, and the I/O is compatible with Java 1.1.
>
Thanks again!!!!>Thanks are best expressed (to me) in the notation of a helpful/correct answer (which you have done), and the assignation of (the remaining) dukes*. ;-)
* After all - checks the title - we have gotten entirely around those 'security restrictions' in a sandboxed application. The reason being that File objects are rarely the correct choice, for applets or JWS apps.

Similar Messages

  • How do I access a .txt file in Xcode for an OSX command line tool?

    I'm in school learning C and C++, and we have to read from and write to .txt files regularly. But I can't figure out how to open a .txt file in Xcode.
    if FILE *buffer = fopen(filename,"r"); where filename is a pointer to a char array holding the name of the file, it works perfectly fine in the terminal. It compiles, in both Xcode and GCC, but when I try to actually open the file in Xcode, my program can never find it and quits the application (so it doesn't crash).
    Long story short, what do I have to do to get my programs in Xcode to read from a .txt file?
    I tried putting a copy of input.txt in every folder within the project, including it in the source files, adding it to target (which I don't wholly understand), I don't know what to do.

    Make sure the filename has an absolute path. If the path is relative it will point to a different location depending on where you run the program from.
    When you run it from within Xcode itself the binary is buried way inside the project hierarchy (you can see where it is by selecting the program in the  Products folder and doing a Show in Finder).
    The safest bet is to always specify a specific directory for any writes you do.
    regards
    As an example for this program in Xcode (assumoing you will be able to see the images)
    The binary is located here

  • How to read data from txt file respectively

    Hi,
    I am triying to form an equation between two known points. I want to do this with the attached VI, the most critical point is that I will read the x1, y1, x2 and y2 coordinates from the same .txt file. They will be written in a .txt file and I will send them to the appropriate channel (x1, y1, x2 and y2) respectively. How can I get data in a rule from a .txt file?
    Could anyone please help me with this issue,
    Best regards. 
    Attachments:
    read from txt file.vi ‏8 KB

    Dear RavensFan,
    Thank you very much for your helps, I am bit new to labview so I usually can not find the appropriate functions easily. And a new problem has rised in my application. I should write the A, B and C numbers in the respective series to the file 2.txt. I am able to write them in a straight forward case but I want to write the next triples (A B C) in the next row. Like this;
    A1 B1 C1
    A2 B2 C2
    A3 B3 C3
    So how can I put new line constant and space constant to my VI? 
    Waiting for your valuable helps,
    Best regards,
    Attachments:
    read_from_txt_fileMOD.vi ‏18 KB

  • I think the lock screen on my ipad takes pictures for security reasons,How do I access this?

    I think the lock screen on my ipad takes pictures for security reasons,How do I access this?

    If the pictures aren't in Photos it's not taking pictures. Didn't you ask this question two hours ago ?

  • In digital editions how to you access the pdf file on your computer - I want to read in acrobat

    in digital editions how to you access the pdf file on your computer - I want to read in acrobat as digital editions too hard to read.@@

    On Mac, try looking in:
    /Users/dug.geo/Documents/Digital Editions
    On Windows, look for "Digital Editions" in "My Documents". If it's not there, look one level above "My Documents".
    If you know the filename of the PDF, you could also try doing a file system search for it.

  • How to read a server side file in Applet?

    When I used ZipFile like this,
    ZipFile zf = new ZipFile("http://xxx.com/res.jar");
    It throwed exception about access denied, File pemission...
    How to read a server side file in Applet?

    You generally can't tell with Stream how many bytes are going to be available. You could download the whole thing into a ByteBuffer, for example, and process it from there.
    Or you can try opening an http connection explicitly (using URL and casting the connection to HttpURLConnection and see if there's a "Content-length" header.

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • How do I access my *.Nef files in finder and aperture?

    How do I access my *.Nef files in finder and aperture?  What are the key strokes to finding these files.
    BACKGROUND:       I shot jpg and nef during recent trips overseas, but can only see the jpg files in finder and aperture.  Are the original, the raw or NeF files?

    Kirby Krieger wrote:
    Unfortunately, that horse is in the clover.  The distinction would force "raw" to be understood as an adjective (which designates a family of image file formats) and not as an actual image file format, which in turn would help many better understand what raw camera files are.  Alas.  I suppose one could substitute "one of the raw file formats" in place of RAW.
    Alas indeed, Kirby. On the other hand, if mentioning it now and again *does* help someone understand the distinction, then I'll continue to mention it, um, now and again.
    And if it prompts someone to ask a question, all the better - I can then ride this particular hobbyhorse around the forum, slaying linguistic sloppiness in my path.
    That Apple are guilty of the same error is disappointing though. As you say, Alas...

  • How to read a whole text file into a pl/sql variable?

    Hi, I need to read an entire text file--which actually contains an email message extracted from a content management system-- into a variable in a pl/sql package, so I can insert some information from the database and then send the email. I want to read the whole text file in one shot, not just one line at a time. Shoud I use Utl_File.Get_Raw or is there another more appropriate way to do this?

    how to read a whole text file into a pl/sql variable?
    your_clob_variable := dbms_xslprocessor.read2clob('YOUR_DIRECTORY','YOUR_FILE');
    ....

  • I have converted a pdf to word. How can I access the Word file from my online account?

    I have converted a pdf to word. How can I access the Word file from my online account? When it says 'download the converted file' I choose a location on my PC and click, but nothing happens. It seems that it can only save the converted file to my online account. I went to my online account but I see no way to look for the file

    Hey Fabrizio,
    You might need to sign up at "https://cloud.acrobat.com/exportpdf" using your Adobe ID credentials to convert your PDF file to Word.
    Do you get the 'download' prompt?
    Also, you can find the converted files by clicking at the 'Files' tab. 
    Please try the same using a different browser and check.
    Hope to hear from you.
    Regards,
    Anubha

  • How do I access my iCloud files from my ipad?

    How do I access my iCloud files from my ipad?

    Try using the PC to launch www.icloud.com

  • How to read data from a file that was formatted by excel?

    Hi everyone, I'm familiar with java.io and the ability to read from files, can anyone tell me how to read data from a file that was formatted by excel? Or at least give me some web references so that I can learn about it?

    http://jakarta.apache.org/poi/hssf/index.html
    HSSF stands for Horrible Spreadsheet Format, but it still works!

  • How can i access filename from file (sender)

    hi All,
    can anybody tell me
    how can i access filename from file (sender)?
    thank u
    swari

    See:
    "SAP NetWeaver XI: Variable Substitution with Adapter-Specific Message Attributes via DynamicConfigurationBean"
    SAP NetWeaver XI: Variable Substitution with Adapter-Specific Message Attributes via DynamicConfigurationBean
    "Accessing Adapter-Specific Attributes through User Defined Function"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70c89607-e4d9-2910-7280-f6746e964516

  • How to read list of all files in folder on application server?

    How to read list of all files in folder on application server?

    Hi,
    First get the files in application server using the following function module.
        CALL FUNCTION 'RZL_READ_DIR_LOCAL'
          EXPORTING
            name     = loc_fdir
          TABLES
            file_tbl = int_filedir.
    Here loc_fdir contains the application server path.
    int_filedir contains all the file names in that particular path.
    Now loop at int_filedir.
    OPEN DATASET int_filedir-name FOR INPUT IN TEXT MODE ENCODING  DEFAULT MESSAGE wf_mess.
    MESSAGE wf_mess.
        IF sy-subrc = 0.
          DO.
            READ DATASET pa_sfile INTO wf_string.
            IF sy-subrc <> 0.
              EXIT.
    endif.
    close datset int_filedir-name.
    endloop.

  • How to read text in .kep files

    hey friends,
    how to read text in .kep files
    please help me .
    with regards,
    s.jagadeesh babu

    Hi,
    check this link:
    http://help.sap.com/saphelp_nw04s/helpdata/en/8f/42a293e35011d29b340000e8a4b41d/content.htm
    .kep files are SapShow Training Files. They can be played with sapshow.exe in Knowledge Warehouse.
    SAP Show is KW Viewer Application. You can use it to see “Kep” files. It can be run in windows without the SAP environment. To run SAP Show (4.6D version) you just need 3 files. First is SAP show executable file, another two are “Sapstg.dll” and “ZLib.dll”. You can easily find these files on internet.
    Regards,
    Niraj

Maybe you are looking for

  • Executable Program (fileName.exe)

    i want to make my java program as an executable file, i mean by double click on the icon the program will be executed. please give me the steps in details. and thank in advance.

  • How to check the VXML Port utilisation in CVP

    Hi, Currently we are using 300 VXML Ports but while monitoring the Active Call in Operational Console it is showing 300 + Active calls in the VXML Server. Please kindly help me to findout  why Active calls status is showing mor than 300 +. Regards, A

  • [solved] In the process of rebuilding firefox with abs

    After I run $ makepkg -g >> PKGBUILD I open up PKGBUILD with nano to edit in the values given on the firefox archwiki page. However, the only thing in PKGBUILD is md5sums=() which doesn't really allow me to continue what I was doing. Anyone have an i

  • Facebook video chat on Macbook with Snow Leopard-Experience???

    I have a Macbook with Snow Leopard 10.6.8, Safari for browser. I'm looking for users of the same who have used or tried to use Facebook video chat and would love to know if it was a good experience or were there any problems and if so what were the n

  • Self Register customization

    Hi experts, how can new fields be added to Self Register page.