Getting current directory from an applet

Hi. How can I get the current directory of my applet running on web without having to worry about permissin. I used the one below:
curDir = System.getProperty("user.dir");
but I get this error:
ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
     at java.security.AccessControlContext.checkPermission(Unknown Source)
any substiture for this? Thanks.

You should be using URLs or similar approaches, and avoiding File, which will
never work with an ordinary applet.
InputStream in = this.getClass().getResourceAsStream("file.txt");That assumes the txt file is in the same place as the current classes .class file.
For example, the same folder or that they are jarred in the same "folder" in the jar.
You can also use a URL directly:
URL url = ...
InputStream in = url.openStream();and you can construct that URL with the help of Applet methods getDocumentBase or getCodeBase:
URL url = new URL(this.getDocumentBase(), "file.txt");That assumes the txt file is in the same folder as the html file in which the applet is embedded.

Similar Messages

  • Cd_links: could not get current directory

    I am installing Oracle8 in Linux and that's the error that I am
    getting: cd_links: could not get current directory
    Does anyone know where is cd_links?
    null

    Claudia (guest) wrote:
    : I am installing Oracle8 in Linux and that's the error that I am
    : getting: cd_links: could not get current directory
    : Does anyone know where is cd_links?
    Which Oracle version are you installing? It's the Enterprise
    Edition or the Standard Edition, did you download it from the
    web? or you got the cd?
    null

  • Get current directory(without user.dir)!!!!

    Dudes,
    need help badly... i need to get the current directory of the jar file where it gets launched from. Since the launching takes place from an html file, the system property "user.dir" does not get set to the current directory. Both the html as well as the jar file is in the same location.
    so in short, i need to get the current dir without using the user.dir that i can later set it explicitly thru my program(to the current dir)

    "Search the CLASSPATH for the first occurence of your jar file... but FFS only do it once, and save the result"
    Cud ya elaborate that statement.
    Also, the reason i wanna know is this : my jar file references all the images that it uses, thru a relative path(./a/b/c.....). So wen i simply double click the jar file, the relative path("./") gets replaced with the current workin directory(from user.dir) and fetching of images works perfectly. But if it is launched via html, the user.dir does not get set to the current working dirctory and as a result the jar file looks for its images in the default location which is the desktop. so it doesnt work
    Now that the context is clear, is there a way out???? or is there any way in which i can set the user.dir from the html itself(maybe by using javascript or somethin??)

  • How to Get Current Date from MS Access in a Select Statement

    From a java method, I want to use JDBC to get the current date from MS Access. In Oracle I would do "select sysdate from dual", but I can't figure out how to do it in MS Access. Here are some of my attempts. I have a table in my Access db called PARM.
    //        String sql = "SELECT '0', NOW() FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT DATE() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW()"; 
    //StringIndexOutOfBoundsException: String index out of range: -1
    //        String sql = "select { fn now() } from parm";
            String sql = "SELECT Date()";
    //java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                return rs.getString(1);
            } else {
                   return null;
              }

    Why are you getting it as a String? You should be getting it as a timestamp.
    Although getString works for me too. There is something else wrong that you haven't shown.
    Here is some shoddy, but simple, test code that demonstrates it working.
    import java.sql.*;
    public class Test{
      public static void main(String args[])throws Exception{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection c = DriverManager.getConnection("jdbc:odbc:stats");
        Statement s = c.createStatement();
        ResultSet rs = s.executeQuery("SELECT NOW()");
        while(rs.next()){
          System.out.println(rs.getTimestamp(1));     
        rs.close();
        s.close();
        c.close();
    }

  • How to get current directory and enviroment variables

    Hello, 
       1.- Is there a global variable to get the actual (project, where is DSB and DSQ files) directory? 
       2.- Is there a way to get User directory like reading enviroment variables from Operative System? 
    Thanks in advance.
    PD: I'm using Dasylab12
    Solved!
    Go to Solution.

    Yes, use System Strings
    For example, ${DATA_FOLDER}.
    The easiest way to get the list is to right click and select Global Strings. The bottom half of the dialog box lists system strings, including date, time, the name of the worksheet, with or without path, the DEFAULT folders for worksheet, data, other, black box, etc. 
    - cj
    Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.

  • How to get current URL from Internet Explorer ?

    Hi,
    I have design an add-on for IE and I'm
    trying to get URL from IE which is currently opened that is which is currently user sees. Is there any way to get it? I want to store that address in label and use it for something useful. Is it possible with C# ?
    I have did the following code to get current URL but it showing last opened URL instead of current URL which is user see
    using SHDocVw;
           SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
                         string filename;
                         foreach (SHDocVw.InternetExplorer ie in shellWindows)
                             filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
                             if (filename.Equals("iexplore"))
                               label1.Text=ie.LocationURL;
                               label1.Text = ie.LocationName;
    and I have tried this one also 
    foreach (InternetExplorer ie innew ShellWindows())
       label1.Text = ie.LocationURL.ToString();
       label2.Text = ie.LocationName.ToString();
    Please give me any suggestion or code to solve this problem.
    Thanks.
    Priyanka

    You already got addon running in the active ie instance. You just need to catch the WindowStateChanged event in every instance so you can write down the last event with OLECMDIDF_WINDOWSTATE_USERVISIBLE somewhere. When you need the active IE instance, just
    pull from your save.
    Note an IE tab may crash and take your addon with it. It is better to start a broker process to store your global data.
    Visual C++ MVP

  • Getting current directory for JFileChooser

    I'm trying to construct a JFileChooser that uses the current directory as its view (and not the default Windows "My Documents" directory path). How can I get the current directory path? File definately doesn't have anything, Toolkit neither.

    I had the same exact question a while ago. The solution is quite simple.
    JFileChooser j = new JFileChooser(".");

  • Getting current directory

    Is there some way to get the current directory path in java?
    -Kevin

    Use
    System.getProperty("user.dir")
    you can get the directory in which you start your java application.

  • Cant get current node from TreeCellEditor isCellEditable().

    I have a custom TreeCellEditor but I do not want to allow the user to edit the root node.
    I was hoping to use isCellEditable() but I can not seem to get the node that is being edited from the EventObject.
    I can get the JTree, (from event.getSource(), but there is no way to get the node that is being tested. I have tried using:
    tree.getEditingPath()
    tree.getLastPathComponent()
    tree.getSelectionPath()But they all return null at the time isCellEditable() is called.
    Does anyone know of a way to get the node that is being tested?
    Thanks,
    Jerome.

    well, that method is meant to be generic such that it decides if editing is possible for the type of event.
    JTable has a separate isCellEditable method, but so does TableModel, so typically, you have a custom table model that implements the method there to return, and in that you know what cell.
    For JTree, I don't know why there's no similar method in the TreeModel interface. There is in JTree, but I really think that should be a function of the model, not the view.
    For JTable, I believe it's only there as a pass-thru, calling the table model's method underneath to get the value.

  • Get current directory?

    Hello
    How do I get the directory a java program is running in?

    System.getProperty("user.dir")

  • How to get current month from filename and bulk insert from text file into table?

    I set up some dynamic SQL to help my bulk copy data from a text file to a table.  This works fine for files that come in every day; I get the previous day’s data, based on the file name that’s placed
    in the folder.  That’s why I’m using the ‘-1’.  The dates will look like this: '20140131', so I'm using type 112.
    declare @fullpath1 varchar(1000)
    select @fullpath1 = '''\\system.local\ms\london\FTP\' + convert(varchar, getdate()-1, 112) + '_INDEXPRICES_EOM.SPC'''
    declare @cmd1 nvarchar(1000)
    print (@cmd1)
    select @cmd1 = 'bulk insert [dbo].[SB_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
    print(@cmd1)
    exec (@cmd1)
    I think the syntax will be somewhat similar to this:
    YEAR(date_column)=YEAR(getdate()) AND MONTH(date_column)=MONTH(getdate())
    I’m not totally sure how to incorporate that into my current syntax.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    I tried a couple versions of this.
    Declare @StartDate Date, @EndDate Date
    Select @StartDate = convert(varchar, getdate()-28, 112), @EndDate = convert(varchar, getdate()-1, 112)
    BEGIN
    declare @fullpath1 varchar(1000)
    select @fullpath1 = '''\\ms\london\FTP\' + ''' between ''' + Convert(Varchar(10), @StartDate, 101) + ''' and ''' + Convert(Varchar(10), @EndDate, 101) + '''_SP.SPC'''
    declare @cmd1 nvarchar(1000)
    print (@cmd1)
    select @cmd1 = 'bulk insert [dbo].[SPBMI_Monthly] from ' + @fullpath1 + ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR=''0x0a'')'
    print(@cmd1)
    exec (@cmd1)
    END
    Here’s the string:
    bulk insert [dbo].[SPBMI_Monthly] from '\\ms\london\FTP\' between '02/03/2014' and '03/02/2014'_SP.SPC' with (FIELDTERMINATOR = '\t', FIRSTROW = 5, LASTROW = 675, ROWTERMINATOR='0x0a')
    The error message I keep getting is:
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'between'.
    Msg 319, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
    I feel like I’m already pushing this thing to the limit. 
    Maybe this last part isn’t possible.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • How to retrieve the  drive letter of the current directory with an applet ?

    The subject says it all.
    I have this html file and when launched it should get the current drive's letter.
    This is how it's done in java, but I dunno how to make it in an applet version.
    import java.*;
    import java.io.File;
    public class test {
    public static void main (String args[]) {
    File dir1 = new File (".");
    String drive = new String();
    try {
    drive = dir1.getCanonicalPath ();
    char driveletter = drive.charAt(0);
    System.out.println ("Drive letter : " + driveletter);
    catch(Exception e) {
    e.printStackTrace();
    Thank you very much for any hint or any idea.
    Gihan.

    Found the solution, used getCodeBase.
    Thank you.
    Gihan.

  • Problem getting "Current Step" from task WLI upgraded from 8.1.5 to 10.3

    Upgraded an EAR file from 8.1.5 to 10.3.
    This included a process that creates a worklist task that shows up in the WLI 10.3 Worklist Console and has a Task Plan ID of /Worklist/Compatibility 8.1.x:9.0.
    Had an interface that extended TaskWorkerControl and am able to get TaskInfo that gives the StateType. In WLI 10.3 this provides the value for Working State.
    Need the value of the Current Step.
    Created a TaskBatchControl but am not able to get any TaskData and so can not get value of the Current Step.
    Is it possible to get TaskData from a worklist task that has a Task Plan ID of /Worklist/Compatibility 8.1.x:9.0?

    This was due to the permissions on the EJB.

  • Getting mulitiple certs from card applet

    Sir
    Actually i got some confusion in the java card applet. But now i want to also store the CA cert on the card.
    But on the process () method i just getting the instruction of get data and it returns the user certificate to the java card.
    case INS_GET_DATA:
    case INS_GET_RESPONSE:
    sendCertificate( apdu );
    break;
    Now i will have two certificates on the card. And i will have to retrieve them explicitly. What should i do now ???

    storing code is:
                   case INS_PUT_DATA:
                        if ( buffer[ISO7816.OFFSET_P1] == 0x06)
                             storeUserCertificate(buffer, ISO7816.OFFSET_CDATA, offset[OFFSET_RECV], len);     
                             if ((cla & 0x10) != 0x00)
                              offset[OFFSET_RECV] += len;
                             else
                              // last command in the chain
                                  userCertSize = (short) (offset[OFFSET_RECV] + len);
                              offset[OFFSET_RECV] = 0;
                        if ( buffer[ISO7816.OFFSET_P1] == 0x07)
                             storeCACertificate(buffer, ISO7816.OFFSET_CDATA, offset[OFFSET_RECV], len);     
                             if ((cla & 0x10) != 0x00)
                              offset[OFFSET_RECV] += len;
                             else
                              // last command in the chain
                                  caCertSize = (short) (offset[OFFSET_RECV] + len);
                              offset[OFFSET_RECV] = 0;
                   break;
         private void storeUserCertificate( byte[] source, short sourceOff, short destOff, short len )
               if ((short) (destOff + len) > FILE_SIZE)
                    ISOException.throwIt(ISO7816.SW_FILE_FULL);
              Util.arrayCopy(source, sourceOff, userCertBuffer, destOff, len);
         private void storeCACertificate( byte[] source, short sourceOff, short destOff, short len )
               if ((short) (destOff + len) > FILE_SIZE)
                    ISOException.throwIt(ISO7816.SW_FILE_FULL);
              Util.arrayCopy(source, sourceOff, caCertBuffer, destOff, len);
    /*********************************************************************/Getting code is:
                   case INS_GET_DATA:
                        if( buffer[ISO7816.OFFSET_P1] == 0x06)
                             sendCACertificate(apdu);
                        else if( buffer[ISO7816.OFFSET_P1] == 0x07)
                             sendUserCertificate(apdu);
                        break;
         private void sendUserCertificate(APDU apdu)
         try{
            // work out how many bytes to send this time and how many will be left
            short remain = (short) (userCertSize - offset[OFFSET_SENT]);
            boolean chain = remain > MAX_APDU;
            short sendLen = chain ? MAX_APDU : remain;
            // Get ready to send
            apdu.setOutgoing();
            apdu.setOutgoingLength(sendLen);
            apdu.sendBytesLong(userCertBuffer, offset[OFFSET_SENT], sendLen);
            // Check to see if there are more APDU's to send
            if (chain) {
                offset[OFFSET_SENT] += sendLen; // count the bytes sent
                ISOException.throwIt(ISO7816.SW_BYTES_REMAINING_00); // indicate there are more bytes to come
            } else {
                offset[OFFSET_SENT] = 0; // no more bytes to send
         catch( APDUException ex)
              ISOException.throwIt(ex.getReason());
         private void sendCACertificate(APDU apdu)
              try
                 // work out how many bytes to send this time and how many will be left
                 short remain = (short) (caCertSize - offset[OFFSET_SENT]);
                 boolean chain = remain > MAX_APDU;
                 short sendLen = chain ? MAX_APDU : remain;
                 // Get ready to send
                 apdu.setOutgoing();
                 apdu.setOutgoingLength(sendLen);
                 apdu.sendBytesLong(caCertBuffer, offset[OFFSET_SENT], sendLen);
                 // Check to see if there are more APDU's to send
                 if (chain)
                     offset[OFFSET_SENT] += sendLen; // count the bytes sent
                     ISOException.throwIt(ISO7816.SW_BYTES_REMAINING_00); // indicate there are more bytes to come
                 else
                     offset[OFFSET_SENT] = 0; // no more bytes to send
              catch( APDUException ex)
                   ISOException.throwIt(ex.getReason());
         }And the output is:
    CA certificate Endoding before sending: 
    In HEX (30820283308201ec020900f730a523693d4eeb300d06092a864886f70d0101050500308185310b300906035504061302504b310f300d06035504080c0650756e6a61623112301006035504070c0949736c616d61626164310e300c060355040a0c055345454353310b3009060355040b0c0249543110300e06035504030c0769766f69746e673122302006092a864886f70d01090116136d2e756d65724073656563732e6564752e706b301e170d3131303332353130313031315a170d3132303332343130313031315a308185310b300906035504061302504b310f300d06035504080c0650756e6a61623112301006035504070c0949736c616d61626164310e300c060355040a0c055345454353310b3009060355040b0c0249543110300e06035504030c0769766f69746e673122302006092a864886f70d01090116136d2e756d65724073656563732e6564752e706b30819f300d06092a864886f70d010101050003818d0030818902818100c72ee8ae34047681fa90e150c7f9ba36c6165cba6d907f7ce1ff29c810661b04b6e531d866842dceac910e969e84eabe5083d635e6fe91a0417e44971c30771ac051a6853fdbb090635d6063081ac8228f7b9bfdf8eb7622403bc5a15425f71307af75b56f27b5f51a1a88c9d43e3b1012b41e0d5e472df17a79b7d486fb707d0203010001300d06092a864886f70d0101050500038181005df2b166258a0af02aa816045be159d8072fe19a4cd2780dbe235220c6328c6ee5540d12720f0a797ea0cb86ca343bf64fb35c1d733e394421209f8a49192046199b321aa17042c34f90947f2a142dd637fbc3c812bdcfc95f6eeee32fa6712c5296781e2398c85b5fcd69010a86bf1e9321fa7b40a5dc1adeef8bf0367426c3)
    total size of the CA certificate is: 647
    In HEX (30820283308201ec020900f730a523693d4eeb300d06092a864886f70d0101050500308185310b300906035504061302504b310f300d06035504080c0650756e6a61623112301006035504070c0949736c616d61626164310e300c060355040a0c055345454353310b3009060355040b0c0249543110300e06035504030c0769766f69746e673122302006092a864886f70d01090116136d2e756d65724073656563732e6564752e706b301e170d3131303332353130313031315a170d3132303332343130313031315a308185310b300906035504061302504b310f300d06035504080c0650756e6a61623112301006035504070c0949736c616d61626164)255 bytes received::Response from card (cert):28416::6f00
    java.security.cert.CertificateException: Could not parse certificate: java.io.EOFException
         at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:109)
         at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:305)
         at smarcard.host.app.SmartCardHostApp.getCACertificate(SmartCardHostApp.java:571)
         at smarcard.host.app.SmartCardHostApp.main(SmartCardHostApp.java:676)
    Caused by: java.io.EOFException
         at java.io.DataInputStream.readFully(DataInputStream.java:180)
         at java.io.DataInputStream.readFully(DataInputStream.java:152)
         at sun.security.util.DerValue.init(DerValue.java:374)
         at sun.security.util.DerValue.<init>(DerValue.java:302)
         at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:104)
         ... 3 moreEdited by: Muhammad Umer on Apr 29, 2011 3:16 PM

  • Get current URL from PL/SQL Package in Portal

    Hello, anyone knows the magic code to get the URL of current Web page from a package running from inside the same page?
    Thx

    You can use the page_url field of the portlet runtime record.

Maybe you are looking for

  • How to get FontType and FormatType in Excel

    How to get the FontType(for eg whether it is Arial or Times New Roman or anything else) and FormatType(whther it is Number or text or date or time etc) for a specified rane of cells in excel ? which function I can use for it or if any one have allrea

  • Oracle 10g - query is very slow in jdbc but not in other tools

    I'm using PreparedStatement to execute a query with some parameters. in sql developer, it just spends 12 seconds but in jdbc, it's around 140 seconds. I disabled "_optim_peek_user_binds" parameter already but it didn't help. alter session set "_optim

  • Sony DSC-TX5 Videos with High Speed (Chipmunk) Sound

    I just imported some videos shot using Sony DSC-TX5 (1280x720 "Fine" MP4). All imported files have their audio sped up, and consequently everything sounds like a chipmunk. Unfortunately, I deleted the movies within camera before checking the imported

  • Timeline moving when I make a Speed change!!  Can this change?!?

    As I'm sure everyone is aware, when you change the Speed of a clip to either slow it down or speed it up the entire rest of the time changes with it. For example, if I speed up a clip I am editing at the beginning of my sequence every clip after it m

  • Onlocation cs4 crash - any solution

    Hi, I have Onlocation install on a pc laptop with vista 64bit, cpu is core duo 2 2.16 and I have 4 go of ram. My hdv sony hvr-z1u was plug into the firewire and my target hard drive was an external HD plug with eSata port for maximum speed. I do a lo