Entry String

Is this someone would have this function already?
To finish a program I would have need of a function that controls what is introduced, if he/it is in the shape of one date as (04 07 2003, 4 7 03, 4.7.03, 4/7/2003,....) that accepts the separator space, ". " either "/ "and if the year is then of 2 numbers it completes with 2000 (example 4.7.03 becomes 04/07/2003). therefore the display after treatment of the entries becomes jj/mm/aaaa, therefore separator "/ ".
If the introduced data don't answer the criterias then one displays a messageBox to inform it that he/it must corrected the data.
Thank you for your help

See SimpleDateFormat and JOptionPane.

Similar Messages

  • I have a minor string issue

    Been looking at the code all day but if I can get a little help this would be great...
    I have a hashtable of buttons and strings and i run a loop to see if they are true...
    public static String checkCaja()
           String temp="";
           for(String name:checkboxes.keySet()){
               // System.out.println(checkboxes.get(name).isSelected()+name);
                if (checkboxes.get(name).isSelected()==true)
                     temp=temp+name+",";
         return temp;
      }the temp returns the strings with an ','. So I will get a
    From one,two,three,four, five,
    I would like to remove the last comma from the last word added... any ideas?
    It should look like one, two,three,four,five
    Thank you in advance!

    As long as we are tweaking code, when you're iterating over names and values, you should use the entry set:
    String f(Map<String, JCheckBox> checkboxes) {
        StringBuffer sb = new StringBuffer();
        for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet()) {
            if(e.getValue().isSelected()) {
                if (sb.length() > 0)
                    sb.append(", ");
                sb.append(e.getKey());
        return sb.toString();
    }I would also go with adding the delimiter every time, then substringing to remove the last one, if any:
    String f(Map<String, JCheckBox> checkboxes) {
        String DELIM = ", ";
        StringBuffer sb = new StringBuffer();
        for(Map.Entry < String, JCheckBox > e : checkboxes.entrySet())
            if(e.getValue().isSelected())
                sb.append(e.getKey()).append(DELIM);
        String s = sb.toString();
        int length = s.length();
        return length > 0 ? s.substring(0, length - DELIM.length()) : s;
    }

  • CS4 index code for subentry repeats entry term

    I'm indexing a book and for each subentry I'm getting a repeat of the entry string concatenated with the subentry value. For example:
    Agencies 357
    Agenciesconsumer rights 359
    Agenciesinterview questions 358
    Agenciesregistry or staffing 357
    Problem appears to be in Word Import where InDesign creates index codes with erroneous content. I've tested with with RTF, Word 97-2003 and Word 2007 format and the results are the same.
    Running CS4 on Windows Vista. Index markers were imported from Word 2007 using Word 97-2003 format. Index worked correctly in Word.
    I've got a 500 page book with complex layout that is ready to go once I get the index fixed!
    Suggestions welcome, thank you.

    Yes, I'm using 6.0.4. The bug is still here.
    I think the easiest work around may be to:
    place the original Word document (with its imbedded index markers) into CS3 (if you have it!)
    generate the index and save the CS3 file
    open the CS3 ID file in CS4
    index generation now works fine
    This should, of course, be done before any formatting begins.
    Exporting the document from CS4 to INX, then loading into CS3 doesn't work.
    It seems the problem is with CS4's inability to properly deal with the second level index markings of Word.

  • Why constant pool with 0 entries?

    I'm writing a tool that parses SWF files. Recently I see some
    SWF file that has constant pool of 0 entries, yet a lot of bytes
    followed. The spec does not describe what this means. For example,
    using swfdump there is something like:
    [00c] 141 DOACTION
    ( 0 bytes) action: Not
    ( 2 bytes) action: If 5
    ( 131 bytes) action: Constantpool(0 entries)
    String:"ˆB" (remainder of 126
    bytes:"\5\0wf_toolbar.swf\0toolbar_mc\0loadMovie\0toobar\0createEmptyMovieClip\0›\16\0Loa dToolbar\0\0\0\20\0–\9\0\8\0\7\1\0\0\0\8\1\28–\2\0\8\2R\23–\16\0\8\1\7\2\0\0\0\8\3\7\2\0\0 \0\8\4=<")
    ( 0 bytes) action: End
    The constant pool contains 0 entries. Yet the total byte size
    of this action is 131 bytes. Clearly there is meaningful
    information contained in these bytes. But I just cannot find in the
    spec how to parse these bytes.
    Anyone can help? Thanks.

    I'm writing a tool that parses SWF files. Recently I see some
    SWF file that has constant pool of 0 entries, yet a lot of bytes
    followed. The spec does not describe what this means. For example,
    using swfdump there is something like:
    [00c] 141 DOACTION
    ( 0 bytes) action: Not
    ( 2 bytes) action: If 5
    ( 131 bytes) action: Constantpool(0 entries)
    String:"ˆB" (remainder of 126
    bytes:"\5\0wf_toolbar.swf\0toolbar_mc\0loadMovie\0toobar\0createEmptyMovieClip\0›\16\0Loa dToolbar\0\0\0\20\0–\9\0\8\0\7\1\0\0\0\8\1\28–\2\0\8\2R\23–\16\0\8\1\7\2\0\0\0\8\3\7\2\0\0 \0\8\4=<")
    ( 0 bytes) action: End
    The constant pool contains 0 entries. Yet the total byte size
    of this action is 131 bytes. Clearly there is meaningful
    information contained in these bytes. But I just cannot find in the
    spec how to parse these bytes.
    Anyone can help? Thanks.

  • Scanner -- how to count spaces a part of a string

    I'm fooling around with Scanner in a little program just to teach myself. Right now, when given the chance to enter data, anything after a space is ignored, so, for example, if one enters "John Smith" for a name entry, on printout it only says "John." How can I fix this?

    Melanie_Green wrote:
    Opps forgot to close the scannerUmmm... As a general rule of thumb... If you open it, close it... and conversely: If you didn't open it, don't close it... any other way lies madness, like having to check if the stream has been closed by something else before every write. Yeck!
    System.in, out, and err are opened and closed for you automatically... so you shouldn't (IMHO) close a scanner on System.in, because it would close the underlying System.in stream... which probably isn't what you wanted to do anyway.
    And (just my humble opinion) I'd regard that "input loop" as "an abuse of loops"... because it's more complicated than it needs to be. However...
    If one where to delegate the "simple attributes" of a "bean-like" class to a Map... Hmmm... the below code concept still isn't (IMHO) actually useful for real apps, because it's limited to String attributes only, but it was an interesting learning exercise none-the-less... and one could conceivably extend it to support all the primitive types, but what's the point... then you may as well just write simple old beans, forget about all the "clever stuff" under the hood, and get on with what the real problems ;-)
    package forums;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Scanner;
    * A base class for simple Data Transfer Objects with only String attributes.
    abstract class DTO
      private static final Scanner SCANNER = new Scanner(System.in);
      protected final String CLASS_NAME;
      private final String[] ATTRIBUTE_NAMES;
      private final String PROMPT_FORMAT;
      private Map<String, String> attributes = new HashMap<String, String>();
      public DTO(String[] attributeNames) {
        this.CLASS_NAME = getClassNameOnly(this.getClass());
        this.ATTRIBUTE_NAMES = attributeNames;
        this.PROMPT_FORMAT = "    %-"+maxLengthOf(attributeNames)+"s : ";
      public void enterAttributes() {
        System.out.println("Please enter the attributes for "+CLASS_NAME+" : ");
        for (String attributeName : ATTRIBUTE_NAMES) {
          String prompt = String.format(PROMPT_FORMAT,attributeName);
          String attributeValue = read(prompt);
          attributes.put(attributeName, attributeValue);
      @Override
      public String toString() {
        StringBuilder result = new StringBuilder();
        result.append("<").append(CLASS_NAME).append(">\n");
        for (Map.Entry<String,String> attr : attributes.entrySet()) {
          result.append("<").append(attr.getKey()).append(">");
          result.append(attr.getValue());
          result.append("</").append(attr.getKey()).append(">\n");
        result.append("</").append(CLASS_NAME).append(">\n");
        return result.toString();
      // ========== HELPER METHODS ==========
      // NOTE: in a real system these would be in various Utilz classes.
      // read from krc.utilz.io.Conzole
      private static String read(String prompt) {
        System.out.print(prompt);
        return SCANNER.nextLine().trim();
      // read from krc.utilz.Clazz
      private static String getClassNameOnly(Class clazz) {
        String fullName = clazz.getName();
        return fullName.substring(fullName.lastIndexOf('.')+1);
      // read from krc.utilz.Stringz
      private static int maxLengthOf(String[] names) {
        int max = names[0].length();
        for(int i=1; i<names.length; i++) {
          max = Math.max(max, names.length());
    return max;
    * A Person object
    class Person extends DTO
    private static final String[] ATTRIBUTE_NAMES = {
    "FirstName", "LastName", "Street", "State"
    public Person() {
    super(ATTRIBUTE_NAMES);
    public class PersonDatabase3
    public static void main (String[] args) {
    try {
    Person person = new Person();
    person.enterAttributes();
    System.out.println(person);
    } catch (Exception e) {
    e.printStackTrace();
    Cheers all. Keith.
    Edited by: corlettk on 21/06/2009 16:47 ~~ Clearer.

  • How do I find classes in a package

    Hi,
    I am working on an automation tool which is to be used for testing public API's in our product. The tool is supposed to work this way:
    1. A developer of the API adds a new java file containing the test code for the API in a particular package (which the tool defines). Then he compiles and places the stuff in a jar. There is also a driver class in this same package path defined by the test tool. E.g.
    driver class: com.aaa.bbb.DriverClass
    new API test file: com.aaa.bbb.TestFile
    Now the driver file's job is to find out all the other classes in this particular package and then do some processing. When I tried doing the getPackage() on this driver class to find out about the package I got back a null.
    Question 1: How can I get the package for a particular class (An ugly way to do this would be to strip it out from the classname)
    Question 2: How can I find out what other classes are there in a package?
    Thanks in advance on this.
    Nikhil Singhal
    You can also send me mails at
    [email protected]

    hai
    i have the same problem to finding the classes in package...
    in my case i know the jars name and i have loaded
    classes using code
    ResourceBundle bundle = ResourceBundle.getBundle("source\\ClasssPath");
    StringTokenizer stToke = new StringTokenizer(bundle.getString("ClassPath"),";");
    String temp;
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    while(stToke.hasMoreTokens())
         temp = stToke.nextToken().trim();
    if(temp.endsWith(".jar"))
    JarFile jar = new JarFile(new File(temp));
         Enumeration en = jar.entries();
         String pathStr;
         while(en.hasMoreElements())
         pathStr = en.nextElement().toString();
         System.out.println("pathStr ="+pathStr);
         if(pathStr.endsWith(".class"))
              System.out.println( classLoader.getResource(pathStr));
              System.out.println(classLoader.loadClass(pathStr.substring(0,pathStr.indexOf(".class")).replace('/','.').trim()));
         else classLoader.loadClass(temp);
    here i am getting the classes in that package using code
         String[] filLis = new File("//it//sella//converter//ptlf//startup//").list();
         int length = filLis.length;
         while(length-- >0)
         System.out.println(">"+filLis[length]);
    but its returnign the class when this classes in locale folder(i.e)its not getting the classes in loaded memory...
    so how to retrieve the class files names using package structure name...
    (i am having more then 20 jars files, inthat inside the jar samepackage structue may appear in more then one jars )
    pls help me in this field..
    Thanx

  • JarEntry has a size of 0

    I am trying to read a few entries from one jar, and add them to another jar. But, when I do, I get an error saying that the size of the entries are 0. Here is my code:
    //Read the entries in from the origenal JAR
         List ResourceJarEntries = new Vector();                    
         JarInputStream resourceIn = new JarInputStream(
              new BufferedInputStream(
                   new FileInputStream("GeneTreeResources.jar")));
         while (resourceIn.available() != 0){
              JarEntry temp = resourceIn.getNextJarEntry();
              System.out.println(temp);
              if (temp != null){
                   System.out.println(temp.getSize());
                   ResourceJarEntries.add(temp);
         resourceIn.close();
    //Write the resources to a new JAR
         JarOutputStream resourceOut = new JarOutputStream(
              new BufferedOutputStream(
                   new FileOutputStream(
                        new File("NewResources.jar"))));
         Iterator origenalEntries = ResourceJarEntries.iterator();
         while(origenalEntries.hasNext()) {
              JarEntry next = (JarEntry)origenalEntries.next();
                    //Don't save if they where in the saved_trees directory
              if (next.toString().indexOf("saved_trees") == -1) {
                   resourceOut.putNextEntry(next);
         resourceOut.flush();
         resourceOut.close();The output I get from the reading demonstrates that the entries being read don't have a valid size:
    male.GIF
    -1
    papyrus.gif
    -1
    female.GIF
    -1
    luke/steve/genetree/Resources.class
    -1
    saved_trees/Map.xml
    -1
    saved_trees/MapPanel.xml
    -1
    saved_trees/TestPanel.xml
    -1
    saved_trees/testAgain.xml
    -1
    null
    And the Error measage in the putNextEntry just seconds that:
    java.util.zip.ZipException: invalid entry size (expected 1925 but got 0 bytes)
    If I read some of the JarEntries from the disk I do not get this error for those entries, but I would for every one I read from the other JAR. Any help on how I can get the full JarEntry with proper size from the origenal JAR?
    thanks.

    A while back I tried to do something similar, I finally got it to work with the following code:
         private final byte[] chunk = new byte[1024 * 1024];
         public void shift(final ZipFile inFile,
                          final File outFile)
              if ((inFile != null) && (outFile != null))
                   ZipInputStream zis = null;
                   ZipOutputStream zos = null;
                   try
                        Manifest manifest = null;
                        final String inFileName = inFile.getName();
                        if (inFileName.endsWith(".jar"))
                             zis = new JarInputStream(new FileInputStream(inFileName));
                             manifest = ((JarInputStream) zis).getManifest();
                        else
                             zis = new ZipInputStream(new FileInputStream(inFileName));
                        if (outFile.getName().endsWith(".jar"))
                             if (manifest != null)
                                  zos = new JarOutputStream(
                                            new FileOutputStream(outFile), manifest);
                             else
                                  zos = new JarOutputStream(
                                            new FileOutputStream(outFile));
                        else
                             zos = new ZipOutputStream(new FileOutputStream(outFile));
                        ZipEntry entry;
                        String entryName;
                        while ((entry = zis.getNextEntry()) != null)
                             entryName = entry.getName();
                             if (!entryName.equals("MANIFEST.MF"))
                                  zos.putNextEntry(entry);
                                  int length = 0;
                                  while (length > -1)
                                       zos.write(chunk, 0, length);
                                       length = zis.read(chunk, 0, chunk.length);
                                  zos.closeEntry();
                             zis.closeEntry();
                   catch (Exception ex)
    //                    System.err.println(ex.toString());
                        ex.printStackTrace();
                   finally
                        closeStream(zis);
                        closeStream(zos);
         }I'll leave it to you to make the neccessary adjustments to fit your specific problem ;-)
    The two closeStream methods are trivial: check for null and if not close the stream in an eneveloping try-catch-block.

  • List updates accumulating loops,index 0 selected

    Hi, I have tried several day solve this.
    ListCellRenderer and ListSelectionListener with list of four male names.
    If you select JUST THE FIRST NAME in the list and press "Change gender" button, the System.print.out shows unnecessarily repeating loops when updating list (=slow down).
    How to avoid extra loops when first name is selected?
    Thanks!
    TestCase.java
    import java.awt.*;
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    public class TestCase {
         boolean packFrame = false;
      public TestCase() {
         TestCaseFrame frame = new TestCaseFrame();
        if (packFrame) {
          frame.pack();
        else {
          frame.validate();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height*9/10;
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width*9/10;
        frame.setLocation(10,10);
        frame.setVisible(true);
      public static void main(String[] args) {
        try {
          UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        catch(Exception e) {
          e.printStackTrace();
        new TestCase();
    TestCaseFrame.java
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    public class TestCaseFrame extends JFrame {
      MyCellRenderer myCellRenderer = new MyCellRenderer();
      BorderLayout borderLayout = new BorderLayout();
      Container contentPane;         
      JPanel panel = new JPanel();
      DefaultListModel defaultListModel = new DefaultListModel();
      JList list = new JList(defaultListModel); 
      JScrollPane scrollPane = new JScrollPane(list);
      ListSelectionModel listSelectionModel;
      JLabel label = new JLabel("<html>Select THE FIRST name and press button! <br>Check System.out.print");
      JButton button_changeGender = new JButton("Change gender");  
      boolean genderNow_male = true;
      String[] names = new String[4];
      public TestCaseFrame() {
           enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
          this.pack();
        catch(Exception e) {
          e.printStackTrace();
      private void jbInit() throws Exception  {
        contentPane = (Container) this.getContentPane();  
        contentPane.setLayout(borderLayout);
        this.setDefaultCloseOperation(3);
        panel.add(label, null);  
        panel.add(scrollPane, null);  
        panel.add(button_changeGender , null);
        button_changeGender.addActionListener(new button_changeGender_actionAdapter(this));
        button_changeGender.setVisible(true);
        button_changeGender.setEnabled(true);
        contentPane.add(panel);
        // default values, gender is now male
        names[0] = "Bill";
         names[1] = "James";
         names[2] = "Martin";
         names[3] = "Peter";
            for (int counter = 0 ; counter < names.length; counter++) {
             defaultListModel.addElement(names[counter]);
        listSelectionModel = list.getSelectionModel(); 
        listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);  
        listSelectionModel.addListSelectionListener(
                new SharedListSelectionHandler(this));   
        list.setSelectedIndex(0);
        list.setVisibleRowCount(7);
        list.setCellRenderer(myCellRenderer);
      void ChangeGender() {    // changes the gender of names in the list if the button was pressed
           System.out.println("\nEntering method ChangeGender");
             defaultListModel.removeAllElements();
                if  (genderNow_male) {
                     genderNow_male = false;
                     names[0] = "Doris";
                     names[1] = "Helen";
                     names[2] = "Nicole";
                     names[3] = "Susan";
                } else {
                     genderNow_male = true;
                     names[0] = "Bill";
                     names[1] = "James";
                     names[2] = "Martin";
                     names[3] = "Peter";
                 for (int counter = 0 ; counter < names.length; counter++) {
                      System.out.println("ChengeGender method (name, index): " + names[counter] + ", " + counter);
                           defaultListModel.addElement(names[counter]);
            list.ensureIndexIsVisible(0);           
            System.out.println("Quitting method ChangeGender\n");          
      void button_changeGender_actionPerformed(ActionEvent e) {
                ChangeGender();
    class button_changeGender_actionAdapter implements java.awt.event.ActionListener {
         TestCaseFrame adaptee;   
         button_changeGender_actionAdapter(TestCaseFrame adaptee) {  // LL1010 oli DelNodesGameFrame adaptee
        this.adaptee = adaptee;
      public void actionPerformed(ActionEvent e) {
        adaptee.button_changeGender_actionPerformed(e);
    class MyCellRenderer extends Container implements ListCellRenderer {      // oli JPanelin tilalla JLabel
         private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);
         private JTextArea textarea;  
         private JPanel cell_panel = new JPanel();
         public MyCellRenderer() {
               textarea = new JTextArea("abcTesting_");
               textarea.setOpaque(true);                      
           public Component getListCellRendererComponent(final JList list,
                    final Object value, final int index, final boolean isSelected,
                    final boolean cellHasFocus) {
                String entry = (String) value;            
                System.out.print("Cell renderer (name, index): " + entry + ", " + index);
                textarea.setText(entry);
                textarea.setColumns(20);
                if(isSelected){
                     System.out.print("   - is selected");
                     textarea.setBackground(list.getSelectionBackground());
                     textarea.setForeground(list.getSelectionForeground());
                } else{
                     System.out.print("   - not selected");
                     textarea.setBackground(list.getBackground());
                     textarea.setForeground(list.getForeground());
                System.out.print("\n");
                setEnabled(list.isEnabled());
                setFont(list.getFont());
                cell_panel.removeAll();
                cell_panel.setOpaque(true);
                cell_panel.setLayout( new FlowLayout(FlowLayout.LEFT));
                cell_panel.add(textarea);  // BorderLayout.WEST,   label_linkTitle
                return cell_panel;           
    class SharedListSelectionHandler implements ListSelectionListener {
         TestCaseFrame adaptee;
         SharedListSelectionHandler(TestCaseFrame adaptee) { 
                  this.adaptee = adaptee;
         public void valueChanged(ListSelectionEvent e) {                 
         ListSelectionModel lsm = (ListSelectionModel)e.getSource();  
         if( !(lsm.isSelectionEmpty()) && !e.getValueIsAdjusting() ) {
                   System.out.print("\nCurrently selected list indexes: ");
                        for (int i = lsm.getMinSelectionIndex(); i <= lsm.getMaxSelectionIndex(); i++) { 
                             if (lsm.isSelectedIndex(i)) {
                                  System.out.print(i + " ");                                                  
                   System.out.print("\n");
    }

    I think you are spending too much time worrying about how Swing does things and not enough time on reducing the complexity of your renderer. You seem to have far too much going on in the body of the renderer.
    Maybe something like
    class MyCellRenderer implements ListCellRenderer
    {      // oli JPanelin tilalla JLabel
        private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);
        private JTextArea textarea;
        private JPanel cell_panel = new JPanel();
        public MyCellRenderer()
            textarea = new JTextArea("abcTesting_");
            textarea.setColumns(20);
            textarea.setOpaque(true);
            cell_panel.removeAll();
            cell_panel.setOpaque(true);
            cell_panel.setLayout(new FlowLayout(FlowLayout.LEFT));
            cell_panel.add(textarea);  // BorderLayout.WEST,   label_linkTitle
        public Component getListCellRendererComponent(final JList list,
                final Object value, final int index, final boolean isSelected,
                final boolean cellHasFocus)
            String entry = (String) value;
            textarea.setText(entry);
            if (isSelected)
                textarea.setBackground(list.getSelectionBackground());
                textarea.setForeground(list.getSelectionForeground());
            } else
                textarea.setBackground(list.getBackground());
                textarea.setForeground(list.getForeground());
            textarea.setEnabled(list.isEnabled());
            textarea.setFont(list.getFont());
            return cell_panel;
    }Edited by: sabre150 on May 23, 2009 11:54 AM

  • Help, Java newbie a little over my head with LDAP

    I'm actually a network admin but I've been dabling in Java for a little while now.
    I am trying to write an app that will allow me to insert and remove attributes to entries in Active Directory.
    I have found some sample code which I have altered to make a "proof of concept" before I start on the actuall app I want.
    The problem I am having is writing into the AD. I can query entries with no error but when I try a modification I get an "DSA is unwilling to perform" LDAPException. I am pretty sure it's not a permissions issue but from reading stuff on here I am begnining to think that it may have something to do with SSL connections. There is commented out code below where I experimented with this but I was unable to connect the the AD when this was in. "unable to connect to the directory server error".
    If anyone can offer me any advice I would be most grateful.
    package LDAPTest;
    import netscape.ldap.*;
    import java.util.*;
    import com.novell.service.ndssdk.jndi.ldap.ssl.*;
    // Simple program to experiment with searching LDAP
    public class FilterSearch
    public static void main(String[] args)
    if(args.length != 6)
    System.out.println("Usage: java FilterSearch " +
    "<host> <port> "+
    "<authdn> <password> "+
    "<basedn> <filter> ");
    System.exit(1);
    String host = args[0];
    int port = Integer.parseInt(args[1]);
    String authid = args[2];
    String authpw = args[3];
    String base = args[4];
    String filter = args[5];
    String[] ATTRS = {"memberOf"};
    int status = -1;
    //SSL experiment that would not connect to the AD server.
    //LDAPConnection ld = new LDAPConnection(new LDAPSSLSocketFactory("com.novell.service.ndssdk.jndi.ldap.ssl.LdapSecureSocketFactory"));
    LDAPConnection ld = new LDAPConnection();
    System.out.println("done connection");
    try
    //Connect to server and authenticate
    ld.connect(host, port,authid,authpw);
    System.out.println("Search filter = " +filter);
    LDAPSearchResults res = ld.search(base, ld.SCOPE_SUB, filter, null, false);
    //Loop on results until complete
    while(res.hasMoreElements())
    try
    //Next Directory entry
    LDAPEntry entry = res.next();
    prettyPrint(entry, ATTRS, ld);
    status=0;
    catch(LDAPReferralException e)
    System.out.println(e);
    continue;
    catch(LDAPException e)
    System.out.println(e.toString() );
    continue;
    LDAPAttribute atrib = new LDAPAttribute("memberOf", "CN=Tight VNC,OU=Staging Transmitter Channels,DC=marimba,DC=local");
    LDAPModification mod = new LDAPModification(LDAPModification.ADD, atrib);
    System.out.println(ld.isAuthenticated());
    try{
    // This is the code the throws the Exception DSA is unwilling to perform.
    ld.modify("CN=smstest0005,CN=MarimbaComputers,CN=Computers,DC=marimba,DC=local", mod);}
    catch(LDAPException e){
    System.out.println(e);}
    catch(LDAPException e)
    System.out.println(e.toString() );
    //Done, so disconnect
    if((ld!=null) && (ld.isConnected()))
    try
    ld.disconnect();
    catch(LDAPException e)
    System.out.println(e.toString());
    System.exit(status);
    public static void prettyPrint(LDAPEntry entry, String[] attrs, LDAPConnection ld)
    System.out.println("DN: " + entry.getDN());
    //Use array to pick attributes. We could have
    //enumerated them all user LDAPEntry.getAttributes
    //but this gives us control of the display order
    for(int i = 0; i < attrs.length; i++)
    LDAPAttribute attr = entry.getAttribute( attrs);
    if (attr == null )
    System.out.println(attrs[i] + " not present");
    continue;
    Enumeration enumVals = attr.getStringValues();
    //Enumerate on values for this attribute
    boolean hasVals = false;
    while ((enumVals!=null) && enumVals.hasMoreElements())
    String val = (String)enumVals.nextElement();
    System.out.println(attrs[i] + ": " + val);
    hasVals=true;
    if(!hasVals)
    System.out.println(attrs[i] + " has no values");
    System.out.println("----------------------");

    OK, I have learned a little about JNDI today and have attempted to implement this using JNDI instead.
    I am now getting the OperationNotSupportedException when attempting to add an attribute to an item in Active Directory.
    here's the code, can anybody who has managed to add data into AD help with this?
    cheers.
    package JNDI;
    import javax.naming.*;
    import javax.naming.directory.*;
    import java.util.*;
    class Getattr
    public static void main(String[] args)
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://hostname:389/");
    env.put(Context.SECURITY_PRINCIPAL, args[0]);
    env.put(Context.SECURITY_CREDENTIALS, args[1]);
    try {
    // Create the initial directory context
    DirContext ctx = new InitialDirContext(env);
    // Ask for all attributes of the object
    Attributes attrs = ctx.getAttributes("CN=smstest0005,CN=MarimbaComputers,CN=Computers,DC=marimba,DC=local");
    for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();)
    Attribute attr = (Attribute)ae.next();
    System.out.println("attribute: " + attr.getID());
    /* Print each value */
    for (NamingEnumeration e = attr.getAll(); e.hasMore();System.out.println("value: " + e.next()));
    // Specify the changes to make
    ModificationItem mod[] = new ModificationItem[1];
    mod[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
    new BasicAttribute("memberOf", "CN=Tight VNC,OU=Staging Transmitter Channels,DC=marimba,DC=local"));
    ctx.modifyAttributes("CN=smstest0005,CN=MarimbaComputers,CN=Computers,DC=marimba,DC=local", mod);
    // Find the surname attribute ("memberOf") and print it
    //System.out.println("memberOf: " + attrs.get("memberOf").get());
    } catch (NamingException e) {
    System.err.println("Problem getting attribute:" + e);

  • Getting two values from a vector

    Hello
    I have a string which when i print it out i get these values.
    hello
    hello
    hello
    hello
    hello
    hello
    hello
    bye
    bye
    bye
    and i want to be able to print out just one of each word
    hello
    ben
    How can i do this with using a vector?
    thanks
    bobby

    Something like this:
    Vector bigVectorOStuff; // declared elsewhere, this contains your Strings
    Vector uniqueEntries = new Vector();
    Enumeration enum = bigVectorOStuff.elements();
    String entry = null;
    while (enum.hasMoreElements())
        entry = (String)enum.nextElement();
        if (!uniqueEntries.contains(entry))
             uniqueEntries.add(entry);
    }That is, loop through the original Vector, getting each element out one at a time. Check to see if this element is in the other Vector, and if not, add it.

  • Error about Source Level only if 5.0?  I'm using Java 1.6?  Maps

    Hello everyone. I was just trying to run some simple Source Code from my book here:
    package mapa;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;
    public class MapTest
         Map<String, String> phonebook = new HashMap<String, String>();
        // constructor
        public example2(String n[], String nums[]) {
           for(int i=0; i< n.length; i++)
               phonebook.put( n, nums[i] );
    public static void main(String[] args) {
    // data
    String [] names = { "Lefty", "Guarav", "Wong", "Rupamay" };
    String [] extns = { "4873", "4810", "3769", "0" };
    // get an instance of this class
    example2 ex = new example2( names, extns );
    // dump out the map
    System.out.println("map: " + ex.phonebook);
    // get the mappings
    Set<Map.Entry<String,String>> s = ex.phonebook.entrySet();
    // iterate over the mappings
    // for (Iterator i = s.iterator(); i.hasNext(); ) {
    for (Map.Entry me : s) {
    Object ok = me.getKey();
    Object ov = me.getValue();
    System.out.print("key=" + ok );
    System.out.println(", value=" + ov );
    and i'm getting the following errors when I run it in Eclipse:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         example2 cannot be resolved to a type
         example2 cannot be resolved to a type
         Syntax error, parameterized types are only available if source level is 5.0
         The type Map.Entry is not generic; it cannot be parameterized with arguments <String, String>
         Syntax error, 'for each' statements are only available if source level is 5.0
         at mapa.MapTest.main(MapTest.java:24)Line 24 is:
      example2 ex = new example2( names, extns );I've compiled things with Eclipse before such as Networking programs and they worked fine, not sure whats wrong with this example.
    Thanks!

    Oops it looks like on that line they are using the Class itself, and they had it renamed to Example2 not MapTest. I changed the code to the following but still getting errros:
    package mapa;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;
    public class MapTest
         Map<String, String> phonebook = new HashMap<String, String>();
        // constructor
        public example2(String n[], String nums[]) {
           for(int i=0; i< n.length; i++)
               phonebook.put( n, nums[i] );
    public static void main(String[] args) {
    // data
    String [] names = { "Lefty", "Guarav", "Wong", "Rupamay" };
    String [] extns = { "4873", "4810", "3769", "0" };
    // get an instance of this class
    MapTest ex = new MapTest( names, extns );
    // dump out the map
    System.out.println("map: " + ex.phonebook);
    // get the mappings
    Set<Map.Entry<String,String>> s = ex.phonebook.entrySet();
    // iterate over the mappings
    // for (Iterator i = s.iterator(); i.hasNext(); ) {
    for (Map.Entry me : s) {
    Object ok = me.getKey();
    Object ov = me.getValue();
    System.out.print("key=" + ok );
    System.out.println(", value=" + ov );
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         The constructor MapTest(String[], String[]) is undefined
         ex.phonebook cannot be resolved or is not a field
         Syntax error, parameterized types are only available if source level is 5.0
         The type Map.Entry is not generic; it cannot be parameterized with arguments <String, String>
         ex.phonebook cannot be resolved or is not a field
         Syntax error, 'for each' statements are only available if source level is 5.0
         at mapa.MapTest.main(MapTest.java:24)

  • Get the duration of all mp3 files inside a directory

    Hello everyone,
    I am working on a little project done with swing. Since I need an mp3 player inside my swing application, I found a really good solution with JavaFX 2. I have never worked with JavaFX before, therefor it seems to me a little bit strange on some parts.
    Anyway.
    I created a button on my application and as soon as somebody presses that button, the application should scan recursivly a unique directory for mp3 files and store the information of artist, title and track length into a database.
    The mp3 player I created is based on the example from this page:
    http://www.java2s.com/Code/Java/JavaFX/Mp3playerwithmetadataviewandcontrolpanel.htm
    I understand the source code for most parts, but some behaivors are not really clear to me. My thoughts about getting the complete length of the mp3 file was
    media.getDuration
    or
    mediaplayer.getTotalDuration
    but both results are NaN if I call .toMillis();
    Instead I need to create a listener (why?)
    private class TotalDurationListener implements InvalidationListener {
        @Override
        public void invalidated(Observable observable) {
          final MediaPlayer mediaPlayer = songModel.getMediaPlayer();
          final Duration totalDuration = mediaPlayer.getTotalDuration();
          totalDurationLabel.setText(formatDuration(totalDuration));
      }and register this listener on the mediaplayer
    mp.totalDurationProperty().addListener(new TotalDurationListener());I can image that the mediaplayer can "host" several media objects somewho and the listener is called as soon as a new media will be added to the mediaplayer in order
    the calculate the overall duration.
    When is this listener exactly called and is there no other ways to get the total length of the mp3 file?
    Here is a minimal example which should work without any external libs
    package de.hauke.schwimmbad.application.playground;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;
    import javafx.application.Platform;
    import javafx.beans.property.ReadOnlyObjectWrapper;
    import javafx.embed.swing.JFXPanel;
    import javafx.scene.Scene;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.media.Media;
    import javafx.scene.media.MediaPlayer;
    import javafx.scene.paint.Color;
    import javafx.util.Duration;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.UIManager;
    public class Testing10 extends JFrame {
         private MediaPlayer mediaPlayer;
         private final ReadOnlyObjectWrapper<MediaPlayer> mediaPlayerWrapper = new ReadOnlyObjectWrapper<MediaPlayer>(
                   this, "mediaPlayer");
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   new Testing10();
              } catch (Exception ex) {
                   System.out.println(ex);
         public Testing10() {
              super();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLayout(null);
              setSize(500, 500);
              setTitle("Testing");
              setLocationRelativeTo(null);
              setResizable(false);
              JButton button = new JButton("Scan");
              button.setBounds(10, 10, 150, 30);
              add(button);
              button.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent arg0) {
                        scan();
              final JFXPanel fxPanel = new JFXPanel();
              fxPanel.setBounds(30, 80, 300, 300);
              add(fxPanel);
              Platform.runLater(new Runnable() {
                   public void run() {
                        initFX(fxPanel);
              setVisible(true);
         private void scan() {
              File directory = new File("C:\\dev\\mp3");
              List<File> mp3Files = new ArrayList<File>();
              for (File file : directory.listFiles()) {
                   if(file.getName().endsWith("mp3")) {
                        mp3Files.add(file);
              for (File file : mp3Files) {
                   System.out.println(file.getAbsoluteFile());
                   getLength(file);
         private Duration getLength(File file) {
              if(mediaPlayer != null) {
                   mediaPlayer.stop();
              final Media media = new Media(file.toURI().toString());
              mediaPlayer = new MediaPlayer(media);
              mediaPlayerWrapper.setValue(mediaPlayer);
              if(media.durationProperty()==null) System.out.println("durationProperty ist null");
              if(media.durationProperty().get()==null) System.out.println(".get() ist null");
              System.out.println("---> " + media.durationProperty().get().toMillis());
              return media.getDuration();
         private void initFX(JFXPanel fxPanel) {
              BorderPane root = new BorderPane();
              Scene scene = new Scene(root, Color.ALICEBLUE);
              fxPanel.setScene(scene);
    }The other question is why do I need a listener for the meta data to be changed in order to get the meta data?
    media.getMetadata().addListener(new MapChangeListener<String, Object>()Why can't I call something like
    media.getMetadata() --> returns a filled map?
    The metadata problem is not included inside the example from above.
    Sorry for my english but I hope everybody can understand the issue.
    Many greetings,
    Hauke

    The nature of the Media class is that it accesses it asynchronously. This means that when you create an instance of it, and then immediately query it, the data you want may not be available yet. This is all in the Javadoc, see the doc for Media:
    The media information is obtained asynchronously and so not necessarily available immediately after instantiation of the class. All information should however be available if the instance has been associated with a MediaPlayer and that player has transitioned to MediaPlayer.Status.READY statusSo you could associate the Media with a MediaPlayer, and then wait until it goes to the Status READY, and then read the length of the Media.
    As for your 2nd question, getMetadata() returns a Map. You can just loop through it:
      for(Map.Entry<String, Object> entry : media.getMetadata()) {
        // etc
      }However, the same restrictions apply as with Media -- you will probably need to wait before the information is available -- that's why the Listener approach works, because it will notify you as soon as the information is added to the map.

  • How do i put classes in package in NetBean Environment

    Hello,
    I install NetBean IDE for developing website using JSP and Servlet. I am using Internal Tomcat provided by this IDE.
    Problem is this i put java classes in the Class folder of Web-INF folder, but i am not able to access these classes from JSp page.
    I try to put these classes in Package but even though i use package option IDE does not put classes in the package.
    I am using internal compiler provided by this IDE for compiling java class' source file.
    What should i do, please help me
    Thank you

    hai
    i have the same problem to finding the classes in package...
    in my case i know the jars name and i have loaded
    classes using code
    ResourceBundle bundle = ResourceBundle.getBundle("source\\ClasssPath");
    StringTokenizer stToke = new StringTokenizer(bundle.getString("ClassPath"),";");
    String temp;
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    while(stToke.hasMoreTokens())
         temp = stToke.nextToken().trim();
    if(temp.endsWith(".jar"))
    JarFile jar = new JarFile(new File(temp));
         Enumeration en = jar.entries();
         String pathStr;
         while(en.hasMoreElements())
         pathStr = en.nextElement().toString();
         System.out.println("pathStr ="+pathStr);
         if(pathStr.endsWith(".class"))
              System.out.println( classLoader.getResource(pathStr));
              System.out.println(classLoader.loadClass(pathStr.substring(0,pathStr.indexOf(".class")).replace('/','.').trim()));
         else classLoader.loadClass(temp);
    here i am getting the classes in that package using code
         String[] filLis = new File("//it//sella//converter//ptlf//startup//").list();
         int length = filLis.length;
         while(length-- >0)
         System.out.println(">"+filLis[length]);
    but its returnign the class when this classes in locale folder(i.e)its not getting the classes in loaded memory...
    so how to retrieve the class files names using package structure name...
    (i am having more then 20 jars files, inthat inside the jar samepackage structue may appear in more then one jars )
    pls help me in this field..
    Thanx

  • Configuration failed for Windows Server Update Services on Server 2012 R2 Essentials (Trial Version)

    Hi,
    I'm trying to setup the WSUS on the Server 2012 R2 Essentials (Trial Version) but with no luck. Below are the logs generated. Hopefully someone can guide me on this. Thanks.
    2014-10-15 12:23:06  Postinstall started
    2014-10-15 12:23:06  Detected role services: Api, UI, WidDatabase, Services
    2014-10-15 12:23:06  Start: LoadSettingsFromXml
    2014-10-15 12:23:06  Start: GetConfigValue with filename=UpdateServices-Services.xml item=ContentLocal
    2014-10-15 12:23:06  Value is true
    2014-10-15 12:23:06  End: GetConfigValue
    2014-10-15 12:23:06  Start: GetConfigValue with filename=UpdateServices-Services.xml item=ContentDirectory
    2014-10-15 12:23:06  Value is C:\WSUS
    2014-10-15 12:23:06  End: GetConfigValue
    2014-10-15 12:23:06  Content directory is C:\WSUS
    2014-10-15 12:23:06  Database roleservice is not installed
    2014-10-15 12:23:06  End: LoadSettingsFromXml
    Post install is starting
    2014-10-15 12:23:06  Start: Run
    2014-10-15 12:23:06  Fetching WsusAdministratorsSid from registry store
    2014-10-15 12:23:06  Value is S-1-5-21-308464661-3380577483-199018475-1000
    2014-10-15 12:23:06  Fetching WsusReportersSid from registry store
    2014-10-15 12:23:06  Value is S-1-5-21-308464661-3380577483-199018475-1001
    2014-10-15 12:23:19  Configuring content directory...
    2014-10-15 12:23:19  Configuring groups...
    2014-10-15 12:23:19  Starting group configuration for WSUS Administrators...
    2014-10-15 12:23:19  Found group in regsitry, attempting to use it...
    2014-10-15 12:23:22  Writing group to registry...
    2014-10-15 12:23:22  Finished group creation
    2014-10-15 12:23:22  Starting group configuration for WSUS Reporters...
    2014-10-15 12:23:22  Found group in regsitry, attempting to use it...
    2014-10-15 12:23:22  Writing group to registry...
    2014-10-15 12:23:22  Finished group creation
    2014-10-15 12:23:22  Configuring permissions...
    2014-10-15 12:23:22  Fetching content directory...
    2014-10-15 12:23:22  Fetching ContentDir from registry store
    2014-10-15 12:23:22  Value is C:\WSUS
    2014-10-15 12:23:22  Fetching group SIDs...
    2014-10-15 12:23:22  Fetching WsusAdministratorsSid from registry store
    2014-10-15 12:23:22  Value is S-1-5-21-308464661-3380577483-199018475-1000
    2014-10-15 12:23:22  Fetching WsusReportersSid from registry store
    2014-10-15 12:23:22  Value is S-1-5-21-308464661-3380577483-199018475-1001
    2014-10-15 12:23:22  Creating group principals...
    2014-10-15 12:23:22  Granting directory permissions...
    2014-10-15 12:23:23  Granting permissions on content directory...
    2014-10-15 12:23:23  Granting registry permissions...
    2014-10-15 12:23:23  Granting registry permissions...
    2014-10-15 12:23:23  Granting registry permissions...
    2014-10-15 12:23:23  Configuring shares...
    2014-10-15 12:23:23  Configuring network shares...
    2014-10-15 12:23:23  Fetching content directory...
    2014-10-15 12:23:23  Fetching ContentDir from registry store
    2014-10-15 12:23:23  Value is C:\WSUS
    2014-10-15 12:23:23  Fetching WSUS admin SID...
    2014-10-15 12:23:23  Fetching WsusAdministratorsSid from registry store
    2014-10-15 12:23:23  Value is S-1-5-21-308464661-3380577483-199018475-1000
    2014-10-15 12:23:23  Content directory is local, creating content shares...
    2014-10-15 12:23:25  Creating share "UpdateServicesPackages" with path "C:\WSUS\UpdateServicesPackages" and description "A network share to be used by client systems for collecting all software packages (usually applications) published
    on this WSUS system."
    2014-10-15 12:23:25  Creating share...
    2014-10-15 12:23:25  Share successfully created
    2014-10-15 12:23:25  Creating share "WsusContent" with path "C:\WSUS\WsusContent" and description "A network share to be used by Local Publishing to place published content on this WSUS system."
    2014-10-15 12:23:26  Creating share...
    2014-10-15 12:23:26  Share successfully created
    2014-10-15 12:23:26  Creating share "WSUSTemp" with path "C:\Program Files\Update Services\LogFiles\WSUSTemp" and description "A network share used by Local Publishing from a Remote WSUS Console Instance."
    2014-10-15 12:23:27  Creating share...
    2014-10-15 12:23:27  Share successfully created
    2014-10-15 12:23:27  Finished creating content shares
    2014-10-15 12:23:27  Stopping service WSUSService
    2014-10-15 12:23:27  Stopping service W3SVC
    2014-10-15 12:23:27  Configuring WID database...
    2014-10-15 12:23:27  Configuring the database...
    2014-10-15 12:23:27  Establishing DB connection...
    2014-10-15 12:23:27  Checking to see if database exists...
    2014-10-15 12:23:28  Database exists
    2014-10-15 12:23:28  Switching database to single user mode...
    2014-10-15 12:23:32  Loading install type query...
    2014-10-15 12:23:32  DECLARE @currentDBVersion       int
    DECLARE @scriptMajorVersion     int = (9600)
    DECLARE @scriptMinorVersion     int = (16384)
    DECLARE @databaseMajorVersion   int 
    DECLARE @databaseMinorVersion   int 
    DECLARE @databaseBuildNumber    nvarchar(10)
    IF NOT EXISTS(SELECT * FROM sys.databases WHERE name='SUSDB')
    BEGIN
        SELECT 1
    END
    ELSE
    BEGIN
        SET @currentDBVersion = (SELECT SchemaVersion FROM SUSDB.dbo.tbSchemaVersion WHERE ComponentName = 'CoreDB')
        SET @databaseBuildNumber = (SELECT BuildNumber FROM SUSDB.dbo.tbSchemaVersion WHERE ComponentName = 'CoreDB')
        DECLARE @delimiterPosition INT = CHARINDEX('.', @databaseBuildNumber)
        IF (@delimiterPosition = 0)
        BEGIN
            RAISERROR('Invalid schema version number', 16, 1) with nowait
            return 
        END 
        SET @databaseMajorVersion = SUBSTRING(@databaseBuildNumber, 1, @delimiterPosition - 1)
        SET @databaseMinorVersion = SUBSTRING(@databaseBuildNumber, (@delimiterPosition + 1), (10 - @delimiterPosition))
        IF @currentDBVersion < 926
        BEGIN
            SELECT 3
        END
        ELSE
        BEGIN
            IF (@scriptMajorVersion > @databaseMajorVersion OR
               (@scriptMajorVersion = @databaseMajorVersion AND @scriptMinorVersion > @databaseMinorVersion))
            BEGIN
                SELECT 2
            END
            ELSE IF (@scriptMajorVersion = @databaseMajorVersion AND
                     @scriptMinorVersion = @databaseMinorVersion)
            BEGIN
                SELECT 0
            END
            ELSE
            BEGIN
                SELECT 4
            END
        END
    END
    2014-10-15 12:23:32  Install type is: Reinstall
    2014-10-15 12:23:32  Creating logins...
    2014-10-15 12:23:32  Fetching account info for S-1-5-20
    2014-10-15 12:23:32  Found principal
    2014-10-15 12:23:32  Found account
    2014-10-15 12:23:32  Got binary SID
    2014-10-15 12:23:35  Fetching WsusAdministratorsSid from registry store
    2014-10-15 12:23:35  Value is S-1-5-21-308464661-3380577483-199018475-1000
    2014-10-15 12:23:35  Fetching account info for S-1-5-21-308464661-3380577483-199018475-1000
    2014-10-15 12:23:35  Found principal
    2014-10-15 12:23:35  Found account
    2014-10-15 12:23:35  Got binary SID
    2014-10-15 12:23:35  Setting content location...
    2014-10-15 12:23:35  Fetching ContentDir from registry store
    2014-10-15 12:23:35  Value is C:\WSUS
    2014-10-15 12:23:40  Swtching DB to multi-user mode......
    2014-10-15 12:23:47  Finished setting multi-user mode
    2014-10-15 12:23:47  Writing DB settings to registry...
    2014-10-15 12:23:47  Marking PostInstall done for UpdateServices-WidDatabase in the registry...
    2014-10-15 12:23:47  Starting service W3SVC
    2014-10-15 12:23:47  Configuring IIS...
    2014-10-15 12:23:47  Start: ConfigureWebsite
    2014-10-15 12:23:51  System.Runtime.InteropServices.COMException (0x80070003): The system cannot find the path specified.
       at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
       at System.DirectoryServices.DirectoryEntry.Bind()
       at System.DirectoryServices.DirectoryEntry.get_AdsObject()
       at System.DirectoryServices.PropertyValueCollection.PopulateList()
       at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
       at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
       at Microsoft.UpdateServices.Administration.UseCustomWebSite..ctor()
       at Microsoft.UpdateServices.Administration.PostInstall.ConfigureWebsite(Int32 portNumber)
       at Microsoft.UpdateServices.Administration.PostInstall.Run()
       at Microsoft.UpdateServices.Administration.PostInstall.Execute(String[] arguments)
    Fatal Error: The system cannot find the path specified.

    2014-10-15 12:23:47  Start: ConfigureWebsite
    2014-10-15 12:23:51  System.Runtime.InteropServices.COMException (0x80070003): The system cannot find the path specified.
    Looks like it failed trying to setup the website.
    2014-10-15 12:23:27  Configuring WID database...
    2014-10-15 12:23:27  Configuring the database...
    2014-10-15 12:23:27  Establishing DB connection...
    2014-10-15 12:23:27  Checking to see if database exists...
    2014-10-15 12:23:28  Database exists
    This also looks like its a RE-installation of WSUS.
    Any chance the "WSUS Administration" v-root is already present and did not get deleted after the last uninstallation?
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • Servlet + Tomcat NoClassDefFoundError

    Hi,
    I am developing a servlet which takes data from Amazon's Web services (in XML format) and then outputs a RSS feed. I use xerces for parsing the XML and then use Rome to output the RSS feed. When I run the servlet then I get the following error.
    However when I run the same code over the commandline, it runs fine, however running it as a servlet, it shows the NoClassDefFoundError . I am also sending the code , it contains the commented out System.out statements which I use when I am running it over the command line
    Thanks
    Gaurav
    javax.servlet.ServletException: Invoker service() exception
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:524)
         at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    java.lang.NoClassDefFoundError
         at form_input.doPost(form_input.java:84)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:466)
         at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:536)
    The Code:
    //JAXP 1.1
    import org.w3c.dom.*;
    import org.w3c.dom.Document;
    import javax.xml.parsers.*;
    import org.apache.xerces.dom.DocumentImpl;
    import org.apache.xerces.dom.DOMImplementationImpl;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.net.*;
    import java.util.Vector;
    import org.apache.xerces.jaxp.*;
    import org.apache.xerces.*;
    import org.apache.xerces.dom.*;
    import org.apache.xerces.parsers.*;
    //import org.apache.xml.serialize.*;
    import org.xml.sax.*;
    import com.sun.syndication.feed.synd.*;
    import com.sun.syndication.io.SyndFeedOutput;
    import com.sun.syndication.io.FeedException;
    import java.io.IOException;
    import java.text.ParseException;
    import java.io.FileWriter;
    import java.io.Writer;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.List;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class form_input extends HttpServlet
    private static final DateFormat DATE_PARSER = new SimpleDateFormat("yyyy-MM-dd");
         public void doGet(HttpServletRequest request, HttpServletResponse response)
                             throws IOException, ServletException
              doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response)
                             throws IOException, ServletException
    response.setContentType("text/xml");
              PrintWriter out = response.getWriter();
              URL data = new URL("http://xml.amazon.com/onca/xml3?t=myWebsite-20&dev-t=1RX5WFR818MJJAEN8A02&KeywordSearch=dogs&mode=books&type=lite&page=1&f=xml");
              URLConnection connection = data.openConnection();
              connection.setUseCaches(false);
    Document doc= null;
              NodeList DetailList = null;
              NodeList DetailChildren = null;
              Node Detail = null;
              Node DetailChild = null;
              Node ChildValue = null;
              DOMParser dparsers = new DOMParser();
              List entries = new ArrayList();
              SyndFeed feed = new SyndFeedImpl();
              SyndEntry entry;
              SyndContent description;
              SyndFeedOutput output = new SyndFeedOutput();
              try
                   feed.setFeedType("rss_1.0");
                   feed.setTitle("Amazon search for dog");
    feed.setLink("http://www.amazon.com");
    feed.setDescription("Amazon search results for dogs");
                   dparsers.parse(new InputSource(connection.getInputStream()));
                   doc = dparsers.getDocument();
                   DetailList = doc.getElementsByTagName("Details");
                   for( int i=0; i<DetailList.getLength(); i++)
                        Detail = DetailList.item(i);
                        DetailChildren = Detail.getChildNodes();
                        entry = new SyndEntryImpl();
                        for( int j=0; j<DetailChildren.getLength(); j++)
                             //Iterate through each of the children and start filling out the RSS thingie
                             //Gotta extract Asin, ProductName, ReleaseDate, Manufacturer, Authors -> Author
                             DetailChild = DetailChildren.item(j);
                             if(DetailChild.getNodeName().equals("Asin"))
                                  //if(DetailChild.hasChildNodes())
                                  //     System.out.println(DetailChild.getNodeName() + " has child nodes");
                                  ChildValue = DetailChild.getFirstChild();
                                  //System.out.println(DetailChild.getNodeName()+ " type = "+DetailChild.getNodeType()+" value="+ChildValue.getNodeValue());
                                  entry.setLink("http://www.amazon.com/exec/obidos/ASIN/"+ChildValue.getNodeValue());
                                  //System.out.println("Match found for Asin");
                             else if(DetailChild.getNodeName().equals("ProductName"))
                                  ChildValue = DetailChild.getFirstChild();
                                  //System.out.println(DetailChild.getNodeName()+ " type = "+DetailChild.getNodeType()+" value="+ChildValue.getNodeValue().length());
                                  if(ChildValue.getNodeValue().length() > 100 )
                                       entry.setTitle(ChildValue.getNodeValue().substring(0,100));
                                  else
                                       entry.setTitle(ChildValue.getNodeValue());
                                  //System.out.println("Match found for ProductName");
                             else if(DetailChild.getNodeName().equals("ReleaseDate"))
                                  ChildValue = DetailChild.getFirstChild();
                                  //System.out.println(DetailChild.getNodeName()+ " type = "+DetailChild.getNodeType()+" value="+ChildValue.getNodeValue());
                                  //System.out.println("ReleaseDate: "+DetailChild.getNodeValue());
                                  //entry.setPublishedDate(DATE_PARSER.parse(DetailChild.getNodeValue()));
                                  entry.setPublishedDate(DATE_PARSER.parse("2004-07-07"));
                                  //System.out.println("Match found for ReleaseDate");
                             else if(DetailChild.getNodeName().equals("Manufacturer"))
                                  ChildValue = DetailChild.getFirstChild();
                                  //System.out.println(DetailChild.getNodeName()+ " type = "+DetailChild.getNodeType()+" value="+ChildValue.getNodeValue());
                                  description = new SyndContentImpl();
                                  description.setType("text/plain");
                                  description.setValue("Initial release of Rome");
                                  entry.setDescription(description);
                        entries.add(entry);
                   feed.setEntries(entries);
                   String fxml = output.outputString(feed);
                   out.println(fxml);
              catch (ParseException ex) {
    // IT CANNOT HAPPEN WITH THIS SAMPLE
    ex.printStackTrace();
    out.println("ERROR: "+ex.getMessage());
              catch( SAXException se)
                   se.printStackTrace();
    out.println("ERROR: "+se.getMessage());
              catch (Exception ex) {
    ex.printStackTrace();
    out.println("ERROR: "+ex.getMessage());

    Hi,
    I am building the servlet for now in
    $TOMCAT_HOME/webapps/examples/WEB-INF/classes ,
    however there is no 'lib' directory in
    $TOMCAT_HOME/webapps/examples/WEB-INF . I created one
    and put the jar files there, but still I get the same
    error. Infact when I start the server, I do not see
    the jar file in CLASSPATH
    Thanks
    GauravYou shouldn't be putting your app in the examples directory.
    You should create a directory under TOMCAT_HOME/webapps for YOUR individual apps. Each one should have a WEB-INF directory under that, and /classes and /lib under that. Your web.xml belongs in the WEB-INF directory. Your .class files, and their package directories, belong under WEB-INF/classes. 3rd party JARs, like JDBC drivers, belong in WEB-INF/lib.
    The problem is that you don't know how to deploy a Web app properly on Tomcat.

Maybe you are looking for

  • XML Publisher 5.6.3 and Emailing

    There has been much discussion on the ability to email requests from EBS and XMLP. I have seen all kinds of work arounds which requires customization. I have a few questions. I have read that in 5.6.3, there is talk of integrated bursting, and some s

  • Bpel xpath query

    Hi, My wsdl contains: <wsdl:message name="BPELProcess1RequestMessage">           <wsdl:part name="payload" type="xsd:string"/> </wsdl:message> <wsdl:message name="BPELProcess1ResponseMessage">           <wsdl:part name="payload" type="xsd:string"/> <

  • Table for alert messages

    Hi All, Is there any table in SAP that stores message ids for which alerts are thrown. My requiremenst is to extract messages for which alerts are thrown. I found ALXMBALERT , but this does not have any entries. Thanks --Pradeep Edited by: pradeep ne

  • Where are the REST of the services stored?

    I am going crazy looking for the services. The ~/library/services folder has my Automator-created services plus a few others. My Services menu has about 80, only 2 or 3 of which are the ones I created. My Services menu OPTIONS, as listed in the Keybo

  • Using img tag with htmlText

    I'm trying to display images within mx:Text components using htmlText.  However, no matter what I try, I can't get an image to display.  The application just displays whitespace where the <img> tag is.  My current code looks something like: