This discussion is archived
2 Replies Latest reply: Jan 7, 2005 5:01 AM by 416044 RSS

getting directory

807596 Newbie
Currently Being Moderated
Hi all

I need some help here. I'm trying to get my program classes directory, trought System class I can only get my working directory that points to "program files\netbeans" and stuff like that.

Can anyone help?
  • 1. Re: getting directory
    807596 Newbie
    Currently Being Moderated
    You need to look at your class path. If you need to get something from your class path use. This allows you to get a file whether it is on disk, in a jar or on the network e.g. HTTP.
    InputStream fileStream = getClass().getClassLoader().getResourceAsInputStream(resourceName);
  • 2. Re: getting directory
    416044 Newbie
    Currently Being Moderated
          * Get CLASSPATH entries.
          * @return List of all entries (Strings of file names) in the current CLASSPATH.
         static public List getClassPath() {
           List result = new ArrayList();
           String classPath = System.getProperty("java.class.path");
           StringBuffer sb = new StringBuffer();
           char pathSeparator = ';'; //default
           String ps = System.getProperty("path.separator");
           if (ps != null && ps.length() > 0) {
               pathSeparator = ps.charAt(0);
           StringCharacterIterator sci = new StringCharacterIterator(classPath);
           char c = sci.first();
           while (c != CharacterIterator.DONE) {
               if (c == pathSeparator) {
               } else {
               c =;
           }//next character
           if (!sb.equals("")) {
           return result;