web start, security element, resource loading problem

Discussion in 'Java' started by Honglin Ye, Aug 19, 2003.

  1. Honglin Ye

    Honglin Ye Guest

    Hi,
    I need to feed a data file to a dataset in a web start application. The program runs fine on local.

    In the jnlp,
    (1) if set security element to j2ee-application-client-permissions,
    I got "ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)"
    (2) if set security element to all-permissions
    I got "java.io.FileNotFoundException: C:\Documents and Settings\hye\Desktop\file:\C:\Program Files\Java Web
    Start\.javaws\cache\http\Dbernoulli.aoc.nrao.edu\P80\DMe2e\DMcalib3\RMCalib3.jar!\calib3\src_parm_pos_datafile.txt (The filename, directory name, or volume label syntax is
    incorrect)
    It seems the class loader picked up an extra prefix "C:\Documents and Settings\hye\Desktop" for the file.

    Any one know why? Thanks

    Honglin Ye



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Honglin Ye, Aug 19, 2003
    #1
    1. Advertising

  2. Honglin Ye

    Roedy Green Guest

    On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <>
    wrote or quoted :

    >Any one know why? Thanks

    Try running Wassup to look at the system properties. That may give you
    a clue.

    See http://mindprod.com/jgloss/wassup.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 19, 2003
    #2
    1. Advertising

  3. Honglin Ye

    Honglin Ye Guest

    Roedy Green wrote:
    > On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <>
    > wrote or quoted :
    >
    >
    >>Any one know why? Thanks

    >
    > Try running Wassup to look at the system properties. That may give you
    > a clue.
    >
    > See http://mindprod.com/jgloss/wassup.html
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.

    ------------------------------------------------------------------------------------------

    Thanks, Roedy, Here is the report from from wassup. I could not find theproblem there.
    Also, the jar file is downloaded, but it did not add to the app manager, why?

    Thanks again.
    Honglin Ye


    awt.toolkit = sun.awt.windows.WToolkit

    file.encoding = Cp1252

    file.encoding.pkg = sun.io

    file.separator = \

    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment

    java.awt.printerjob = sun.awt.windows.WPrinterJob

    java.class.path = D:\PROGRA~1\Java\J2RE14~1.1\classes

    java.class.version = 48.0

    java.ext.dirs = D:\PROGRA~1\Java\J2RE14~1.1\lib\ext

    java.home = D:\PROGRA~1\Java\J2RE14~1.1

    java.io.tmpdir = C:\DOCUME~1\hye\LOCALS~1\Temp\

    java.library.path = D:\Program Files\Netscape\Netscape;.;C:\WINNT\System32;C:\WINNT;d:\Program Files\Netscape\Netscape\;D:\oracle\ora81\bin;C:\Program
    Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;"D:\Program
    Files\Hummingbird\Connectivity\7.00\Accessories\";D:\Program Files\Rational\common;D:\BorlandEnterpriseServer\bin;D:\oracle\ora81\bin;C:\Program
    Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;"D:\Program
    Files\Hummingbird\Connectivity\7.00\Accessories\";D:\Program
    Files\Rational\common;D:\BorlandEnterpriseServer\bin;d:\j2ee\bin;d:\j2sdk1.4.0\bin;D:\j2ee\jakarta-ant-1.3\bin;D:\BorlandEnterpriseServer\bin

    java.specification.name = Java Platform API Specification

    java.specification.vendor = Sun Microsystems Inc.

    java.specification.version = 1.4

    java.vendor = Sun Microsystems Inc.

    java.vendor.url = http://java.sun.com/

    java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi

    java.version = 1.4.1

    java.vm.info = mixed mode

    java.vm.name = Java HotSpot(TM) Client VM

    java.vm.specification.name = Java Virtual Machine Specification

    java.vm.specification.vendor = Sun Microsystems Inc.

    java.vm.specification.version = 1.0

    java.vm.vendor = Sun Microsystems Inc.

    java.vm.version = 1.4.1-b21

    line.separator = [binary chars: 0x0d 0x0a i.e. CrLf, \r\n]

    os.arch = x86

    os.name = Windows 2000

    os.version = 5.0

    path.separator = ;

    sun.boot.class.path =
    D:\PROGRA~1\Java\J2RE14~1.1\lib\rt.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\i18n.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\sunrsasign.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\jsse.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\jce.jar;D:\PROGRA~1\Java\J2RE14~1.1\lib\charsets.jar;D:\PROGRA~1\Java\J2RE14~1.1\classes;D:\PROGRA~1\Java\J2RE14~1.1\lib\jaws.jar

    sun.boot.library.path = D:\PROGRA~1\Java\J2RE14~1.1\bin

    sun.io.unicode.encoding = UnicodeLittle

    user.dir = d:\Program Files\Netscape\Netscape

    user.home = C:\Documents and Settings\hye

    user.language = en

    user.name = hye

    user.timezone = America/Denver




    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Honglin Ye, Aug 20, 2003
    #3
  4. Honglin Ye

    Roedy Green Guest

    On Tue, 19 Aug 2003 16:44:49 -0600, Honglin Ye <>
    wrote or quoted :

    > It seems the class loader picked up an extra prefix "C:\Documents and Settings\hye\Desktop" for the file.

    So it is looking in user.home.
    user.home = C:\Documents and Settings\hye

    I think the key may be dumping out
    new File(".").getCanonicalPath().

    To find out what the current directory is under various circumstances.

    Just WHAT is it looking in that directory for?

    My guess is some sort of properties file.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 20, 2003
    #4
  5. Honglin Ye

    Roedy Green Guest

    On Wed, 20 Aug 2003 13:52:18 -0600, Honglin Ye <>
    wrote or quoted :

    >java.io.FileNotFoundException: file:\C:\Program Files\Java Web Start\.javaws\cache\http\Dbernoulli.aoc.nrao.edu\P80\DMe2e\DMcalib3\RMCalib3.jar!\calib3\alias_datafile.txt


    It is hard debugging without seeing the source code. I have to make a
    lot of guesses. That is not a valid FILE name. That is an URL of a
    member of a jar. I think you were trying to use file methods to read
    a jar member. Zips are something like subdirectories, but are not
    treated that way by Java. You need totally different methods to read
    them.


    See http://mindprod.com/fileio.html for how to read given an URL.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 20, 2003
    #5
  6. Honglin Ye

    Roedy Green Guest

    On Thu, 21 Aug 2003 12:09:06 -0600, Honglin Ye <>
    wrote or quoted :

    > private void readFromFile(URL aliasFileName) {
    > FileReader fileReader;
    > char data[] = new char[1024];


    Please reread my earlier post. You cannot use FileReader to look
    inside a Jar.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 21, 2003
    #6
  7. Honglin Ye

    Honglin Ye Guest

    Roedy Green wrote:
    > On Thu, 21 Aug 2003 12:09:06 -0600, Honglin Ye <>
    > wrote or quoted :
    >
    >
    >> private void readFromFile(URL aliasFileName) {
    >> FileReader fileReader;
    >> char data[] = new char[1024];

    >
    >
    > Please reread my earlier post. You cannot use FileReader to look
    > inside a Jar.
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


    Did read it. Read from FileReader is to verify the point - it does
    not work for the file that is in a jar file.

    Again, the objective is to use borland TableDataSet classs. The
    construct of that class takes a file name as argument. The question
    is - what if that file is in a jar file? It seems that it behaves
    just like the case of using FileReader.



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Honglin Ye, Aug 21, 2003
    #7
  8. Honglin Ye

    Roedy Green Guest

    On Thu, 21 Aug 2003 15:00:59 -0600, Honglin Ye <>
    wrote or quoted :

    >
    >Did read it. Read from FileReader is to verify the point - it does
    >not work for the file that is in a jar file.


    If you want to read an URL you have to do something like this.
    Are you telling me this does NOT work on file:! Jar-type URLs?
    If not, then you are going to have to use the ZIP classes.

    // Read Locale-encoded chars ( usually 8 bit ) from a buffered URL.
    // WARNING! unsigned Applets may only read from the server they were
    loaded from.
    // Sockets are a low level tool. For HTTP you will see all the headers
    and length bytes.
    // For HTTP normally you want the HttpURLConnection rather than
    Socket.
    // To copy/download files see
    http://mindprod.com/products.html#FILETRANSFER.

    // import java.io.*;
    // import java.net.*;

    // O P E N
    // Generate an HTTP GET Command
    URL url = new URL( "http://www.billabong.com:80/songs/lyrics.txt" );
    URLConnection urlc = url.openConnection();
    urlc.setAllowUserInteraction( false );
    urlc.setDoInput( true );
    urlc.setDoOutput( false );
    urlc.setUseCaches( false );
    urlc.connect();
    long length = urlc.getContentLength(); // -1 if not available
    // if you want to analyse the URL
    String protocol = url.getProtocol(); // http
    String host = url.getHost(); // www.billabong.com
    String file = url.getFile(); // lyrics.txt
    int port = url.getPort();// 80
    InputStream is = urlc.getInputStream();
    InputStreamReader eisr = new InputStreamReader( is,"Cp437" );
    // Cp437 is IBM OEM.
    // See "encoding" in the Java glossary for alternatives
    // such as UnicodeBig for 16-bit, big-endian Unicode characters.
    BufferedReader br = new BufferedReader( eisr, 4096 /* buffsize */ );

    // R E A D
    char[] ca = new char[1024];
    int charsRead = br.read( ca );
    String line;
    // File being read had better have a terminal \n!
    line = br.readLine();
    // line == null means EOF
    int aChar;
    aChar = br.read();
    // aChar == -1 means EOF

    // C L O S E
    br.close();
    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 21, 2003
    #8
  9. Honglin Ye

    Honglin Ye Guest

    Roedy Green wrote:
    > On Thu, 21 Aug 2003 15:00:59 -0600, Honglin Ye <>
    > wrote or quoted :
    >
    >
    >>Did read it. Read from FileReader is to verify the point - it does
    >>not work for the file that is in a jar file.

    >
    >
    > If you want to read an URL you have to do something like this.
    > Are you telling me this does NOT work on file:! Jar-type URLs?
    > If not, then you are going to have to use the ZIP classes.
    >
    > // Read Locale-encoded chars ( usually 8 bit ) from a buffered URL.
    > // WARNING! unsigned Applets may only read from the server they were
    > loaded from.
    > // Sockets are a low level tool. For HTTP you will see all the headers
    > and length bytes.
    > // For HTTP normally you want the HttpURLConnection rather than
    > Socket.
    > // To copy/download files see
    > http://mindprod.com/products.html#FILETRANSFER.
    >
    > // import java.io.*;
    > // import java.net.*;
    >
    > // O P E N
    > // Generate an HTTP GET Command
    > URL url = new URL( "http://www.billabong.com:80/songs/lyrics.txt" );
    > URLConnection urlc = url.openConnection();
    > urlc.setAllowUserInteraction( false );
    > urlc.setDoInput( true );
    > urlc.setDoOutput( false );
    > urlc.setUseCaches( false );
    > urlc.connect();
    > long length = urlc.getContentLength(); // -1 if not available
    > // if you want to analyse the URL
    > String protocol = url.getProtocol(); // http
    > String host = url.getHost(); // www.billabong.com
    > String file = url.getFile(); // lyrics.txt
    > int port = url.getPort();// 80
    > InputStream is = urlc.getInputStream();
    > InputStreamReader eisr = new InputStreamReader( is,"Cp437" );
    > // Cp437 is IBM OEM.
    > // See "encoding" in the Java glossary for alternatives
    > // such as UnicodeBig for 16-bit, big-endian Unicode characters.
    > BufferedReader br = new BufferedReader( eisr, 4096 /* buffsize */ );
    >
    > // R E A D
    > char[] ca = new char[1024];
    > int charsRead = br.read( ca );
    > String line;
    > // File being read had better have a terminal \n!
    > line = br.readLine();
    > // line == null means EOF
    > int aChar;
    > aChar = br.read();
    > // aChar == -1 means EOF
    >
    > // C L O S E
    > br.close();
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


    I have no problem read from stream which connected in a file in a jar.
    You can look at my code I posted on 8/21, 12:09pm. I have a method there
    called readFromStream. That method works even it is not the same as you
    posted here. Infact, we do not necessarily need URLConnnection, the
    following line is sufficient to get the stream. It works.
    -----------
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("calib3/alias_datafile.txt");
    -----------

    The situation is this:
    TableDataSet takes file, but not file in a jar.
    read from filereader does not work for file in a jar.
    read from stream works well for file in a jar.
    TableDataSet does not take stream directly.
    How to make TableDataSet to work if the file is in a jar?



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Honglin Ye, Aug 22, 2003
    #9
  10. Honglin Ye

    Honglin Ye Guest


    >
    > The situation is this:
    > TableDataSet takes file, but not file in a jar.
    > read from filereader does not work for file in a jar.
    > read from stream works well for file in a jar.
    > TableDataSet does not take stream directly.
    > How to make TableDataSet to work if the file is in a jar?
    >
    >


    It turns out extremly easy. Just 3 lines of code!

    private TextDataFile aliasDataFile = new TextDataFile();
    public TableDataSet aliasTableDataSet = new TableDataSet();

    InputStream dataStream = this.getClass().getClassLoader().getResourceAsStream("calib3/alias_datafile.txt");
    aliasDataFile.load(aliasTableDataSet, dataStream, null);

    Thanks.

    Honglin Ye






    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Honglin Ye, Aug 22, 2003
    #10
  11. Honglin Ye

    Roedy Green Guest

    On Fri, 22 Aug 2003 09:53:01 -0600, Honglin Ye <>
    wrote or quoted :

    > TableDataSet takes file, but not file in a jar.
    > read from filereader does not work for file in a jar.
    > read from stream works well for file in a jar.
    > TableDataSet does not take stream directly.
    >How to make TableDataSet to work if the file is in a jar?


    Perhaps that you problem is how do you get an InputStream but you
    want in Reader. How do you convert?

    Again the fileIO amanunesis is your friend.
    http://mindprod.com/jgloss/fileio.html

    The technique I showed earlier works for any URL. The getResource
    technique works only for stuff on the resource path. Obviously
    getResource or getResourceAsStream is simpler if you can make that
    assumption.



    InputStreamReader eisr = new InputStreamReader( inputStream,"Cp437" );
    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Aug 22, 2003
    #11
    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. Dirc Khan-Evans
    Replies:
    1
    Views:
    882
    Karl Seguin
    Oct 17, 2005
  2. avishosh
    Replies:
    2
    Views:
    10,526
    avishosh
    Aug 8, 2004
  3. HANM
    Replies:
    2
    Views:
    691
    Joseph Kesselman
    Jan 29, 2008
  4. Heinrich Moser
    Replies:
    1
    Views:
    447
    Heinrich Moser
    Mar 27, 2008
  5. Vaibhav Joshi
    Replies:
    0
    Views:
    878
    Vaibhav Joshi
    Aug 2, 2011
Loading...

Share This Page