Can't get current working directory

I can't figure out how to get the current directory my applet is running from. I want to loop through the currentdirectory/folderA. Below is my code:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import javax.swing.JApplet;
import javax.swing.*;
import java.net.*;
public class Refresh4 extends JApplet{     
     String curDir = System.getProperty("user.dir");
    String myFile = curDir+"/folderA";//folderA within the directory that the applet is in
    File f = new File(myFile);
    long orig;
    long upd=0;
    long comp=0;
    javax.swing.Timer timer;
    int j = 1;
     public void init(){//initial run class, runs create gui once and sets up timer
        try {
            javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
        } catch (Exception e) { }
        timer = new javax.swing.Timer(2000,taskPerformer);//runs every 2 seconds
          timer.start();//starts timer
  ActionListener taskPerformer = new ActionListener() {//called by timer every 2 seconds, executes FileReader
      public void actionPerformed(ActionEvent evt) {
           j++;
           FileReader(j);
public void FileReader(int j){//reads all files in directory and checks their modified time/date
     File[] files = f.listFiles();
          for (int i=0;i<files.length;i++){
               File nFile = files;
               orig = nFile.lastModified();
               if (orig>upd){
                    upd = orig;
          if(upd>comp){
               comp = upd;
               if(j>2){
               try {
                    getAppletContext().showDocument
                    (new URL("javascript:doAlert(\""+j+"\")"));
               catch (MalformedURLException me) { }          

String curDir = System.getProperty("user.dir");That does get the current directory.
However, your applet should not "need" to know this, nor rely on it. If you want to open resources (such as graphic images), those resources should be packaged with the applet (like in a jar file on the server), and the applet would get them using codebase- or classpath- based APIs -- not file system-based APIs.

Similar Messages

  • How can I get the working directory of a project from an Annotation Processor in Java

    I am writing an annotation processor in Java and in this annotation processor I want to be able to find a file in the Project hierarchy of the project on which I am using this annotation processor. Through the annotation I can pass in the path of the file I am searching for relative to the project root but i cannot retrieve the project's working directory.
    Let's say that the processor is MyCustomProcessor and I am using it on the project MyProject. I want to be able to access(read) a file (a properties file) from the project structure of MyProject from the "process" method of MyCustomProcessor.
    I have read this link Eclipse - Annotation processor, get project path but when I use their solution I get a null returned from the StandardJavaFileManager.getLocation(StandardLocation.SOURCE_PATH) call.
    Some more details regarding the implementation:
    MyAnnotationProcessor:
    @SupportedAnnotationTypes(value = {"MyAnnotation" })
    @SupportedSourceVersion(RELEASE_6)
    public class MyCustomProcessor extends AbstractProcessor {
    @Override public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
    for (final Element element : roundEnv.getElementsAnnotatedWith(MyAnnotation.class)) {
    <!-- Here is where I would like to get the working directory !-->
    More details about the testing and development environment: Eclipse Kepler, JRE 1.7.
    If you need more details just ask.

    There is an identical post with an answer located at this link.

  • How to get  current working directory of the ftp server,in java application

    Hi All,
    I?m FTP?ing the file using java.net.url.
    Here is the snippet of the code:
    public void ftpFile()throws ChrsException
    try
    System.out.println("FTPing the file '"+localfile+"'");
    OutputStream os = openUploadStream(targetfile);
    FileInputStream is = new FileInputStream(localfile);
    byte[] buf = new byte[16384];
    int noOfBytesRead;
    while (true)
    //Read the data from the source File into buf
    noOfBytesRead = is.read(buf);
    if (noOfBytesRead <= 0)
    break;
    //Writes the data present in the buf to the target file
    os.write(buf, 0, noOfBytesRead);
    os.close();
    is.close();
    close();
    System.out.println ("The file '"+localfile+"' is Sucessfully FTP'd to '"+targetfile+"'");
    catch (MalformedURLException malExcp)
    System.out.println ("Invalid URL. Error in FTP'ing the file: \""+localfile+"\"");
    catch(IOException ioe)
    System.out.println ("Error in FTP'ing the file: \""+localfile+"\"");
    private OutputStream openUploadStream(String targetfile) throws MalformedURLException, IOException
    URL url = null;
    //Creates a URL object with FTP protocol
    if (user == null)
    url = new URL("ftp://" + host + "/" + targetfile + ";type=i");
    else
    url = new URL("ftp://" + user + ":" + password + "@" + host + "/" + targetfile + ";type=i");
    urlc = url.openConnection();
    //Get the OutputStream that writes to this connection.
    OutputStream os = urlc.getOutputStream();
    return os;
    Now I need to find what the current directory is when the user logs in with username and password on to the FTP server in java.
    Thanks in Advance.

    as soon as user logs in he is taken to the directory
    "ftproot/pub/abc".
    now If I execute pwd command , is hould be able to
    get to know tht user is under "ftproot/pub/abc"Three respected posters, well two plus me ;-), have just told you otherwise. The information about the current directory is (a) secure and (b) useless to the user, as he can't do anything with it. The user doesn't want to know that at all and you shouldn't try to tell him. And in any case FTP doesn't support it, again for security reasons, so you can't do it.
    Just accept it.

  • How to list the top 10 largest files in the current working directory ?

    How can I list the top 10 largest files in the current working directory in Solaris ?

    execute below....to get the large files in order.. change the <FS>
    find /<FS> -type f -size +1024 -ls | awk '{print $11, $7}' | sort -rn +1 | awk '{print $1, $2/1024/1024 "MB"}' | /bin/more

  • Determin current working directory using java program

    HI:
    I would like to know is there anyway that I can determine what my current working directory is, using a java program??
    Thanks,
    Sincerely,
    Karen

    Properties sysProperties = System.getProperties();
    String currDir = sysProperties.get("user.dir");Here's a list of all the properties you can get from sysProperties:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties()

  • Can t get to work tint2 launcher

    I'm a beginner in arch linux and i'm trying to figure out why the laucher don't show up in my panel,
    i've set up the panel the way i want but i would like to have a few launcher
    I've try serveral thing but i can't get it to work,
    and chromium.desktop and gparted.desktop do exist in /usr/share/applications/
    tks
    Here my tint2rc
    # TINT2 CONFIG FILE
    # horizontal panel
    # squared taskbars
    # idirae config
    # Background definitions
    # ID 1
    rounded = 0
    border_width = 1
    background_color = #808080 20
    border_color = #ffffff 10
    # ID 2 - task active
    rounded = 0
    border_width = 0
    background_color = #feffff 0
    border_color = #d8d8d8 0
    # ID 3 - task
    rounded = 0
    border_width = 0
    background_color = #F5F5DC 0
    border_color = #000000 0
    # ID 4
    rounded = 0
    border_width = 1
    background_color = #888888 0
    border_color = #ED2323 60
    # ID 5 - taskbar
    rounded = 0
    border_width = 1
    background_color = #feffff 10
    border_color = #ffffff 10
    # ID 6 - active taskbar
    rounded = 0
    border_width = 1
    background_color = #feffff 30
    border_color = #ffffff 30
    # ID 7 - tooltip
    rounded = 3
    border_width = 0
    background_color = #222222 90
    border_color = #222222 90
    # ID 8
    rounded = 0
    border_width = 1
    background_color = #888888 20
    border_color = #888888 20
    # Panel
    panel_monitor = all
    panel_position = top left horizontal
    panel_items = LTSBC
    panel_size = 100% 32
    panel_margin = 0 1
    panel_padding = 3 3
    panel_dock = 0
    wm_menu = 1
    panel_layer = bottom
    panel_background_id = 1
    # Panel Autohide
    autohide = 0
    autohide_show_timeout = 0.3
    autohide_hide_timeout = 1.5
    autohide_height = 6
    strut_policy = follow_size
    # Taskbar
    taskbar_mode = multi_desktop
    taskbar_padding = 5 2
    taskbar_background_id = 5
    taskbar_active_background_id = 6
    taskbar_name = 1
    taskbar_name_background_id = 0
    taskbar_name_active_background_id = 0
    taskbar_name_font = Crisp 12
    taskbar_name_font_color = #ffffff 30
    taskbar_name_active_font_color = #ffffff 50
    # Tasks
    urgent_nb_of_blink = 20
    task_icon = 1
    task_text = 0
    task_centered = 1
    task_maximum_size = 20 20
    task_padding = 0 0
    task_background_id = 3
    task_active_background_id = 2
    task_urgent_background_id = 4
    task_iconified_background_id = 3
    # Task Icons
    task_icon_asb = 80 0 0
    task_active_icon_asb = 100 0 0
    task_urgent_icon_asb = 100 0 0
    task_iconified_icon_asb = 80 0 0
    # Fonts
    task_font = BankGothic Md BT 10
    task_font_color = #696969 60
    task_active_font_color = #696969 100
    task_urgent_font_color = #696969 100
    task_iconified_font_color = #696969 60
    font_shadow = 0
    # Launcher
    launcher_icon_theme = elementary
    launcher_padding = 2 2
    launcher_background_id = 1
    launcher_icon_size = 20
    # Specify icon theme names with launcher_icon_theme.
    # if you have an XSETTINGS manager running (like xfsettingsd), tint2 will follow your current theme.
    #launcher_icon_theme = AwOkenWhite
    # Each launcher_item_app must be a full path to a .desktop file
    launcher_item_app = /usr/share/applications/chromium.desktop
    launcher_item_app = /usr/share/applications/gparted.desktop
    # Clock
    time1_timezone = :/usr/share/zoneinfo/dir/Canada/Eastern
    time1_format = %I:%M %p
    time1_font = BankGothic Md BT 9
    #time2_format = %A, %B %d
    #time2_font = Ubuntu-L 7
    clock_font_color = #ffffff 80
    clock_padding = 5 0
    clock_background_id = 5
    clock_lclick_command = gsimplecal
    #lock_rclick_command =
    # System Tray
    systray = 1
    systray_padding = 2
    systray_sort = right2left
    systray_background_id = 5
    systray_icon_size = 20
    systray_icon_asb = 100 0 0
    # Tooltips
    tooltip = 0
    tooltip_padding = 2 2
    tooltip_show_timeout = 0.0
    tooltip_hide_timeout = 0.0
    tooltip_background_id = 7
    tooltip_font_color = #ff0000 100
    tooltip_font = Roboto-Thin normal 9.0
    # Mouse
    mouse_middle = none
    mouse_right = toggle
    mouse_scroll_up = toggle
    mouse_scroll_down = iconify
    # Battery
    battery = 1
    battery_hide = never
    battery_low_status = 10
    battery_low_cmd = notify-send "battery low"
    bat1_font = sans 8
    bat2_font = sans 6
    battery_font_color = #ffffff 80
    battery_padding = 5 0
    battery_background_id = 5
    # End of config
    Last edited by jolejo07 (2013-07-05 01:39:25)

    I've try but can't get it working ether, i've download from Aur but when i'm trying to use the PKGBUILD with makepkg
    it telling me
    ==> ERROR: Cannot find the fakeroot binary required for building as non-root user.
    ==> ERROR: Cannot find the strip binary required for object file stripping.
    Last edited by jolejo07 (2013-07-05 01:45:21)

  • Can't get Mail working properly

    I just got my new MacPro this week, and it's really great except for I can't get Mail working right. I've set up my accounts and a few emails come through, though not many, and because it's been a week since I've been online, there should be many more than that. Also, I can't send any emails at all, no matter what I do. They will eventually go into my Sent box, but I've been sending them to myself to see if it's working, and they never come through. I spent an hour on the phone yesterday with the tech support for my ISP, and they told me that I'd have to talk to the Apple techs because they didn't have current info for *Mail 3.1*, the version I have, that the latest they had was for 2.something. So I called the Apple tech support and spent 2 hours on the phone with them, and they weren't able to help me get it going correctly either. It keeps giving me error messages such as Connection Failed, or Unable to Receive Mail, saying "there may be a problem with the mail server or network" and that "the connection to the server on ... port has timed out." I'm on DSL and am always online, so I know it's not the internet connection that's the problem. Can anybody give me some advice on what I should try? Any help will be gratefully appreciated!

    Is your ISP Verizon, Demon, or Glocalnet, then it might be Apples biggest Leopard Bug in conjunction with these ISP:s POP-servers.
    The one that randomly changes the settings in "advanced" from "password" to "APOP".
    The visual result of this bug is that you will get a popup-box where Mail asks you to enter your password. (Which is useless entering, since the preference settings are changed.)
    My advice counts only when you are supposed to use "password" as the correct setting in "Advanced" and in conjunction with some ISP:s.
    Michael

  • Can't get webutil working on AS

    Hi All,
    As topic, I can't get webutil working on the application server. I can run individual forms or sessions that do not utilise webutil. As soon as I have baseHTMLjinitiator/baseHTMLjpi/baseHTML defined in the bit of the formsweb.cfg that I am using, I get this problem. The webutiljini.htm etc are located in the forms/server directory as they should be.
    I've got it working fine on my 10.1.2 developer suite XP platform.
    I've been trying without success on the App Server. Version 10.1.2 under Win2003
    I have been right through the installation instructions several time trying to see what I have missed.
    I have installed version 1.0.6 of webutil and version 1.8 of jacob.
    I try and run the wu_test_106 form, and all I get is "Applet Started" at the bottom of the browser window, and a blank browser window.
    My URL is
    http://10.64.125.51:7778/forms/frmservlet?config=webutil1
    The config in the formsweb.cfg is:
    [webutil1]
    WebUtilArchive=frmwebutil.jar,jacob.jar
    WebUtilLogging=off
    WebUtilLoggingDetail=normal
    WebUtilErrorMode=Alert
    WebUtilDispatchMonitorInterval=5
    WebUtilTrustInternal=true
    WebUtilMaxTransferSize=16384
    baseHTMLjinitiator=webutiljini.htm
    baseHTMLjpi=webutiljpi.htm
    baseHTML=webutilbase.htm
    archive_jini=frmall_jinit.jar
    archive=frmall.jar
    lookAndFeel=generic
    form=wu_test_106.fmx
    width=100%
    height=100%
    separateFrame=True
    The other parameters are default. If I try a different form name it makes no difference.
    I've done the other configuration stuff, default.env, signing jar files, etc.
    The java console just shows:
    Oracle JInitiator: Version 1.3.1.22
    Using JRE version 1.3.1.22-internal Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\griggto01
    Proxy Configuration: Manual Configuration
    Proxy:
    Proxy Overrides:
    JAR cache enabled
    Location: C:\Documents and Settings\griggto01\Oracle Jar Cache
    Maximum size: 50 MB
    Compression level: 0
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    q: hide console
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    Loading http://10.64.125.51:7778/forms/java/frmwebutil.jar from JAR cache
    RegisterWebUtil - Loading WebUtil Version 1.0.6
    Thanks for your help.
    Tony

    Hi Tony,
    Form your post it doesn't look like jacob.jar is being loaded. Can you confirm that you have the following files in the <ORACLE_AS>/forms directory:
    java\
       jacob.jar
       frmwebutil.jar
    webutil\
       d2kwut60.dll
       jacob.dllAlso open up your default.env file and check that
    ORACLE_HOME         -- is correct
    FORMS_PATH            -- has the path where wu_test_106.fmx is located
    WEBUTIL_CONFIG      -- is correct (I've experienced what you describe when this path was invalid)
    CLASSPATH             -- contains frmwebutil.jar
    Regards
    Tom Casserly

  • Where can I get current info on SysAdmin Certification(s) for Mac OSX SL and Lion?

    Where can I get current info on SysAdmin Certification(s) for Mac OSX SL and Lion? The Apple website for this is "under construction" for weeks now...
    Thanks,
    [email protected]

    Certification test for OS X 10.7 Lion are not available yet. I assume they will be nearly identical to the test of 10.5 and 10.6. Hopefully, the reason the certification website has been down for a while is that they are updating it with the new information. Though I really wouldn't expect any 10.7 certification test to be available for 2-4 months. Peachpit Press didn't publish their training material for 10.6 until October even though 10.6 was released in August.
    As far as the 10.6 Certifications:
    Certified Support Professional, 10.6 requires the 9L0-403 exam.
    Certified Technical Coordinator, 10.6 requires the 9L0-403 as well as the 9L0-510 (Server Essentials) exams.
    The information for the Certified System Administrator, 10.6 is "hidden" on the integral7 website but according to this Wikipedia entry, you need to pass the 9L0-510 Server Essentials exam as well as these three:
    Directory Services
    Deployment
    Security and Mobility

  • How can we get current time date with resultset?

    Dear All,
    I have to insert current time date in the table.So,i need to get the current time and date with result set.So,I will first get the time date and then insert it into the table.
    I know how can we get current time and date without resultset.i have created this function its working.But now i want to use this.mean using resultset i want to put in the table.
    How can i do this?
    public static String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
    public static String now() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    return sdf.format(cal.getTime());
    }

    yuck. Why not simply set a "new java.sql.Date()" to the SQL parameter in question?

  • I have 2 itunes accounts - one work a/c and one home a/c, but when i sign in at home only my home songs appear even if I sign in my work a/c. I have authorised both computers to show both a/cs. How can I get my work a/c songs to appear at home?

    I have 2 itunes a/cs one at work and one at home. Both computers are authorised for the 2 a/cs, but I can;t get my work a/c songs to show on my home computer, even though I sign in my work a/c, and I can't get my home songs to show up on the  work computer even though I sign in my home a/c. V. frustrating!

    Hi,
    You will have to manually copy your music. Get a pen-drive big enough to accommodate all your music. And follow these steps:
    1. Create a new folder on the pen-drive.
    2. Copy the music from your work computer to the folder you just created. It's in (yourhomefolder)>Music>iTunes>iTunes Media>Music if you're using a Mac, or in C:\Users\(yourusername)\Music\iTunes\iTunes Media\Music if you're using Windows.
    3. Now on your home computer quit iTunes, and copy your music from work to the "Automatically Add to iTunes" folder in (yourhomefolder)>Music>iTunes>iTunes Media.
    4. Start iTunes. It will automatically start to process the files and move them to the appropriate place.
    Repeat these steps with your music from home on your work computer. Also I suggest to use only one iTunes account if possible.
    Hope it helps
    Regards,
    Gábor

  • How can we get ADFSecurity work when used in OC4J, OID and OAM?

    I am getting error in http server log "mod_oc4j: Response status=499 and reason=Oracle SSO, but failed to get mod_osso global context."
    But I am not using Oracle SSO and my client doesn't want to use it either, I am using OAM SSO(CoreIDSSO) in my configuration. Please read the details below.
    I am using ADFSecurity in an app that is protected by OAM. To migrate ADFSecurity permissions from
    system-jazn-data.xml to OID, I used JAZNMigrationTool to populate OID with Grantees and Permissions. OAM gives login page, and authentication works fine.
    But ADFSecurity is not working. ADFComponent Delete button is enabled even for roles that dont have permissions for the iterator delete.
    - The app works fine when I use without OAM. ADF Security permissions work fine.
    - The app works fine when used with OAM, but with ADFSecurity disabled (enforce=false).
    - When I enforce ADFSecurity alongwith OAM, ADFSecurity is not working.
    In the doc "Oracle Containers for J2EE Security Guide b28957", there is a mention of use of CoreIDPrincipal for permissions. Our OID Permissions entries show
    LDAPRealmRole for attribute orcljaznprincipal. I am not sure if this could be the reason.
    We have configured AccessServerSDK for the SOA instance and have policy for the urls in the policy manager. We have entries in orion-application.xml, orion-web.xml and system-jazn-data.xml as per the documentations.
    How can we get ADFSecurity work when used with OID and OAM?

    Have you been able to successfully integrate OAS with OAM & OID? We have similar requriement and so far we have not been able to get it working.
    We have application specific roles which we map to OID roles using orion-application.xml.
    Any pointers to achieve this would be greatly appreciated.
    thanks,
    Dipal

  • In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?

    In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?
    Thank you!

    When you erased the disk did you select Mac OS Extended Journaled as the format option?

  • My hard drive crashed on my Imac 24" 2009, i put in a new hard drive 2TB and a SSD drive 240 GB and removed the opticdrive. What external DVD can I get to work with the IMac? The Apple super drive is not compatible.

    My hard drive crashed on my Imac 24" 2009,  I installed a new hard drive 2TB and a SSD drive 240 GB and removed the optical drive.
    What external DVD can I get to work with the IMac?                              The Apple super drive is not compatible.

    Virtually any DVD burner that can connect to your Mac will work. They start at $40 on Amazon.

  • Hello, I use MAC AIR OSX 10.6.8 and have Adobe CS2, that I was using 2 years ago on my older computer. I stopped using it because it would close down in the middle of work. Now I would like to reinstall it on the MacAir but I can not get it working. It te

    Hello, I use MAC AIR OSX 10.6.8 and have Adobe CS2, that I was using 2 years ago on my older computer. I stopped using it because it would close down in the middle of work. Now I would like to reinstall it on the MacAir but I can not get it working. It tells Adobe doesnT support my System. But I can not update my old version or activate it. What can I do?

    The mac you want to install photoshop cs2 on is running mac os x 10.6.8 Snow Leopard?
    (photoshop cs2 won't run on intel macs with mac os x newer than snow leopard)
    Did you ever have cs2 installed on this particular computer before?
    If the problem is that you already installed cs2, but it won't activate, that's because adobe took the activation servers offline for some older adobe products such as cs2.
    You'll need to use the non activation version of cs2 from here and the supplied serial number:
    Activation server shut down for Creative Suite 2, Acrobat 7, and Macromedia products

Maybe you are looking for

  • Unable to Install Oracle 12 on Windows Server 2012 R2

    Hello: I have attemted several times to install Oracle 12c Release 1 on a Windows 2012 R2 server but it fails during the Net Configuration phase. I've the log file but I am not able to dicern anything of value from it. Any help will be appreciated. V

  • Address Book no longer able to import multiple vCards

    In Leopard, and at least Tiger before that, when importing vCards into Address Book, you could hold down the Command key and import multiple vCards at once rather than only one at a time. You can no longer do this in Snow Leopard. This is extremely i

  • Right Click,Context Menu problem in Page Personalize

    Hi All, I am using EP6.40 and SP 13.  When I right click on portal content, showing context menu. I entered into Page Personalize  page by clicking options icon(Right-top corner of the page)-> personalize, a pop up window opened. In there, When I rig

  • Fonts: how does it work..?

    Hi, I have added a new Truetype font to our SAP system with SE73. All fine. But do I also need this font on the client desktops in order to have it shown? I have added a "Univers" font but if I don't have it on my PC I can't see it in SAP. Is this co

  • Better ripper than iTunes on Leopard?

    hi guys, i love iTunes and am not interested in starting another flame war... but i was never quite satisfied with the ripping and encoding quality. on my Linux box I use cdparanoia (a ripper based on cdda2wav) and LAME (mp3encoder) and i like the fl