How do I rewrite current code for java 1.3

I'm using the code below that is written for java 1.4. I have been told that the company can not push JRE 1.4 to the company, and that I need to write my code for java 1.3. I'm using org.w3c.dom for my create xml, etc.
Is there a java 1.3 option to the 1.4? Any help would be very appreciated.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.List;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
public class Sametime extends JFrame implements ActionListener {
    private int indentation = -1;
    JPanel panel = new JPanel();
    JTextArea jta = new JTextArea(
    //Instructions for user
    "For a successful buddy list migration do the following:\n"
    + "1. Save your current Sametime Buddy List to your PC.\n   "
    + "The default location should be: C:/Program Files/Lotus/Sametime Client.\n"
    + "  A. Open the Sametime Client.\n"
    + "  B. Click on People\n"
    + "  C. Click on Save List.\n"
    + "  D. Save as your first.last.dat\n"
    + "     Ex. john.doe.dat\n"
    + "NOTE: If you have AOL contacts in your Sametime buddy list they will not be migrated.\n");
    JButton browse = new JButton("Continue");
    JButton exit = new JButton("Exit");
    public Sametime() {
        super("Sametime Buddy List Migration");
        setSize(610, 245);
        Container c = this.getContentPane();
        c.add(panel);
        browse.addActionListener(this);
        exit.addActionListener(this);
        panel.add(jta);
        panel.add(browse);
        panel.add(exit);
        jta.setEditable(false);
        setLookAndFeel();
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } //end Sametime
    public class DATFilter extends javax.swing.filechooser.FileFilter {
        public boolean accept(File f) {
            //if it is a directory -- we want to show it so return true.
            if (f.isDirectory())
                return true;
            String extension = getExtension(f);//get the extension of the file
            //check to see if the extension is equal to "dat"
            if ((extension.equals("dat")))
                return true;
            //default -- fall through. False is return on all
            //occasions except:
            //a) the file is a directory
            //b) the file's extension is what we are looking for.
            return false;
        }//end accept
        public String getDescription() {
            return "dat files";
        }//end getDescription
         * Method to get the extension of the file, in lowercase
        private String getExtension(File f) {
            String s = f.getName();
            int i = s.lastIndexOf('.');
            if (i > 0 &&  i < s.length() - 1)
                return s.substring(i+1).toLowerCase();
            return "";
        }//end getExtension
    }//end class DATFilter
    public void actionPerformed(ActionEvent e) {
        //Default Location for JFileChooser search
        String error = "The file selected is not a .dat file!\n"
        + "Please select your recently saved .dat file and try again.";
        JFileChooser fc = new JFileChooser("/Program Files/Lotus/Sametime Client");
        fc.setFileFilter(new DATFilter());
        fc.setFileSelectionMode( JFileChooser.FILES_ONLY);
        String user = System.getProperty("user.name");// finds who the current user is
        if (e.getSource() == browse) {
            int returnVal = fc.showSaveDialog(Sametime.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                //if (fc.getSelectedFile().getName().equals(".dat")){
                if (fc.getSelectedFile().getName().endsWith(".dat")){ // checks to see if selected file is .dat
                }else{
                    JOptionPane.showMessageDialog(null, error, "Wrong File", JOptionPane.ERROR_MESSAGE);
                    return;
                }//end else
                try {
                    String[] contactArray = parseDatFile(fc.getSelectedFile());
                    Document document = createXMLDocument(contactArray);
                    saveToXMLFile(
                    document,
                    new File(
                    "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// looks for directory for list
                    "contacts-list_migration.ctt"));
                } catch (Exception exc) {
                    File f = new File("C:/Documents and Settings/" + user +"/My Documents/OLCS/");// setting directory for list if not there
                    boolean yes = true;
                    yes = f.mkdir();// creating directory
                    try {
                        String[] contactArray = parseDatFile(fc.getSelectedFile());
                        Document document = createXMLDocument(contactArray);
                        saveToXMLFile(
                        document,
                        new File(
                        "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// used only if the directory didn't exist
                        "contacts-list_migration.ctt"));
                        //exc.printStackTrace();// not sure if this is needed?
                    } catch (Exception exc1) {
                        exc1.printStackTrace();
                    }//end inner catch
                }// end catch
            }// end if
            if(returnVal==JFileChooser.CANCEL_OPTION){
                String Warning = "You did not migrate your Sametime buddy list at this time.";
                JOptionPane.showMessageDialog(null, Warning, "Migration Canceled", JOptionPane.WARNING_MESSAGE);
                return;
            }else{
                String thankyou = "Thank You for Migrating your Sametime buddy list to OLCS"
                + "\nYour new OLCS buddy list has been saved to:"
                + "\nC:/Documents and Settings/" + user +"/My Documents/OLCS"
                + "\n as: Contact-List_migration.ctt"
                + "\n\n To be able to use Contact-List_migration.ctt for Windows Messenger:"
                + "\n1. Log into Windows Messenger."
                + "\n2. Click on File"
                + "\n3. Click on 'Import Contacts from a Saved File...'"
                + "\n4. Open OLCS in My Documents"
                + "\n5. Click on 'Contact-list_migration.ctt'"
                + "\n6. Click Open to import the list."
                + "\n   A window will pop up confirming that you want to add all of the contacts"
                + "\n   Click 'yes'"
                + "\n   Your buddy list is ready to be used.";
                JOptionPane.showMessageDialog(null, thankyou, "Migration Completed", JOptionPane.INFORMATION_MESSAGE);//Change this when defualt directory is known.
            }//end if else statement
        } //end if
        System.exit( 0 );
        if (e.getSource() == exit) {
            System.exit( 0 );
        } //end if
    } //end actionPerformed
    String[] parseDatFile(File datFile)
    throws Exception    {
        List list = new ArrayList();
        BufferedReader br = new BufferedReader(new FileReader(datFile));
        String line;
        while ((line = br.readLine()) != null) {
            line = line.trim();
            if (line.indexOf("U") != 0)
                continue;
            int p = line.indexOf("::");
            if (p == -1)
                continue;
            line = line.substring(p + 2).trim();
            if (line.indexOf("AOL") == 0)
                continue;
            p = line.indexOf(",");
            if (p != -1)
                line = line.substring(0, p);
            line = line.trim() + "@mci.com";
            if (list.indexOf(line) == -1)
                list.add(line);
        }//end while
        br.close();
        String[] contactArray = new String[list.size()];
        list.toArray(contactArray);
        return contactArray;
    }// end String
    // setting up the XML file
    Document createXMLDocument(String[] contactArray) throws Exception {
        DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = dBF.newDocumentBuilder();
        DOMImplementation domImpl = builder.getDOMImplementation();
        Document document = domImpl.createDocument(null, "messenger", null);
        Element root = document.getDocumentElement();
        Element svcElm = document.createElement("service");
        Element clElm = document.createElement("contactlist");
        svcElm.setAttribute("name", "Microsoft RTC Instant Messaging");
        svcElm.appendChild(clElm);
        root.appendChild(svcElm);
        for (int i = 0; i < contactArray.length; i++) {
            Element conElm = document.createElement("contact");
            Text conTxt = document.createTextNode(contactArray);
conElm.appendChild(conTxt);
clElm.appendChild(conElm);
}//end for
return document;
}// end Document
void saveToXMLFile(Document document, File xmlFile) throws Exception {
OutputStream os =
new BufferedOutputStream(new FileOutputStream(xmlFile));
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");//puts information on seperate lines
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");//gives the XML file indentation
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(os);
transformer.transform(source, result);
os.close();
}//end saveToXMLFile
public static void main(String[] args) {
Sametime st = new Sametime();
ImageIcon picIcon = new ImageIcon(st.getClass().getResource("/images/mci.gif"));//Change when default is known!
st.setIconImage(picIcon.getImage());
} //end main
private void setLookAndFeel() {
try {
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch (Exception e) {
System.err.println("Could not use Look and Feel: " + e);
} //end catch
} //end void setLookAndFeel
} //end public class Sametime

Are there features of Java 1.4 that you specifically took advantage and are there any particular lines you are having problems with or did you just freak and post it here?
Basically compile it under Java 1.3 and see what complains. I've done several projects that compile under 1.2, 1.3, and 1.4.

Similar Messages

  • How can i rewrite this code into java?

    How can i rewrite this code into a java that has a return value?
    this code is written in vb6
    Private Function IsOdd(pintNumberIn) As Boolean
        If (pintNumberIn Mod 2) = 0 Then
            IsOdd = False
        Else
            IsOdd = True
        End If
    End Function   
    Private Sub cmdTryIt_Click()
              Dim intNumIn  As Integer
              Dim blnNumIsOdd     As Boolean
              intNumIn = Val(InputBox("Enter a number:", "IsOdd Test"))
              blnNumIsOdd = IsOdd(intNumIn)
              If blnNumIsOdd Then
           Print "The number that you entered is odd."
        Else
           Print "The number that you entered is not odd."
        End If
    End Sub

    873221 wrote:
    I'm sorry I'am New to Java.Are you new to communication? You don't have to know anything at all about Java to know that "I have an error," doesn't say anything useful.
    I'm just trying to get you to think about what your post actually says, and what others will take from it.
    what does this error mean? what code should i replace and add? thanks for all response
    C:\EvenOdd.java:31: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=true;
    ^
    C:\EvenOdd.java:35: isOdd(int) in EvenOdd cannot be applied to ()
    isOdd()=false;
    ^
    2 errors
    Telling you "what code to change it to" will not help you at all. You need to learn Java, read the error message, and think about what it says.
    It's telling you exactly what is wrong. At line 31 of EvenOdd.java, you're calling isOdd(), with no arguments, but the isOdd() method requires an int argument. If you stop ant think about it, that should make perfect sense. How can you ask "is it odd?" without specifying what "it" is?
    So what is this all about? Is this homework? You googled for even odd, found a solution in some other language, and now you're just trying to translate it to Java rather than actually learning Java well enough to simply write this trivial code yourself?

  • Tips on how to write efficient  java code for java mapping

    hi
    I do not have much knowledge in Java
    Can anybody tell me some tips on how to write efficient and optimised java code to be used in java mapping
    Thanks,
    Loveena

    hi D'za,
    JAVA in xi
    A very important place where you will use JAVA in XI is while doing your Mapping. There will be cases when JAVA MAPPING is the best solution to go for. There are 2 types of Parsers available for JAVA Mapping. DOM Parser and SAX parser. Just got through the following links to understand more on Java Mapping and the APIs available.http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/package-summary.html http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Document.html http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    JAVA mapping -
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii /people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping /people/amol.joshi2/blog/2006/03/10/think-objects-when-creating-java-mappings /people/sameer.shadab/blog/2005/09/29/testing-abap-mapping
    sample code for java mapping
    Re: Example code DOM PARSER API -
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html DOM --- /people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs tutorial sax and dom
    For a tutorial on the methods of SAX and DOM http://java.sun.com/webservices/docs/1.1/tutorial/doc/
    SAX AND dom PARSER ( BY thorsten) -
    example /people/thorsten.nordholmsbirk/blog/2006/08/10/using-jaxp-to-both-parse-and-emit-xml-in-xi-java-mapping-programs java mapping example ( testing and debugging) /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    regards
    biplab
    Use a Good Subject Line, One Question Per Posting - Award Points

  • HOw to create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • How can we write the code for opening the command prompt and closing the

    how can we write the code in java for opening the command prompt and closing the cmd prompt from eclipse (cmd prompt should close when click on the turminate button in eclipse)

    rakeshsikha wrote:
    how can we write the code for opening the command prompt and closing theBy typing in Eclipse (which you seemingly have)?

  • How can i watch native code for hashCode() in Object class?

    How can i watch native code for hashCode() in Object class?

    Those are two different requirements. You still haven't told us why you want the first one.
    The second one is called JNI - Java Native Interface. There is a forum here, and a large amount of documentation, and a book about it.

  • How do I generate redemption code for creative cloud?

    how do I generate redemption code for creative cloud?

    On October 27th 2014, you have purchased two CC (one complete &one photography) under the same Adobe ID. That is the reason you are being asked for a code because under one Adobe ID only one CC can be activated(twice).
    Please contact Adobe Support or you can inbox me privately the CC order number  that you would like to cancel.
    You can also check if the host file has Adobe entry or not as if Adobe entries are there then also CC can ask for serial number. You can check the host by the followinh method.
    Creative cloud do not need a serial number. it will be using your Adobe ID on which you have purchased the creative cloud membership.
    So you need to login with your Adobe ID and password to activate the cloud membership.
    Log out & log back in of the CC Desktop App.
    In case it is not signing in successfully please try the following:
    I don't know which operating system you are working on so i am giving you some steps windows and MAC OS:
       Windows:
       In windows 7 navigate to following location:
         /windows/system32/drivers/etc
       1. look out for "Hosts" file
       2. Open it with notepad
       3. Check if you have any entry for Adobe
       4. Remove the entries and try again launching any product from CC
      Mac:
       1. Please click on "Go" and navigate to /private/etc
       2. Open "hosts" file and check out for any entries for Adobe.com
       3. Remove the entries and save the file
       4.  try again launching any product from CC
      Please refer to Creative Cloud applications ask for serial number
    Hope it helps you.
    Regards
    Rajshree
    Cannot license Illustrator CC after buying subscription

  • How to create an address code for PO delivery address?

    Hi Guys,
    How to create an address code for the delivery address in the purchase order? Please explain me with details.....
    Thanks
    Raja

    delivery adress records can be created with transaction MEAN.
    the number is purely internal.
    In ME21N you can then search by name (you will certainly not know the number)

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • How to setup a company code for material management

    Hi,
    While creating material in MM01, in sales org tab, when I gave plant XXXX, it is giving an error "Company code YYYY is not setup for material management".
    So can you help me , how to setup a company code for material management
    Help is appreciated
    thanks
    DIL

    Hello Sendil,
    You can maintain it with trns code OMSY or MMPI/MMPV.
    Hope this helps
    Regards
    Arif Mansuri

  • How do I redeem my code for Mountain Lion OS X when I can't find a redeem button in the Mac App store anywhere please?

    How do I redeem my code for Mountain Lion OS X when I can't find a redeem button in the Mac App store anywhere please?
    How do I find the redeem button?  What do I have to do?

    Welcome to Apple Support Communities
    Open the Mac App Store and press the Redeem button:

  • How to create the exe file for java project.

    How to create the exe file for java project.
    am done the project in java swing , i like to create the project in exe format, so any one help for me,
    send the procedure for that.
    thanking u.

    How to create the exe file for java project.Have you ever heard of google? I pasted your exact "question" into a google search:
    http://www.google.com/search?q=How+to+create+the+exe+file+for+java+project.
    and got several useful links.
    Better search terms might yield even better results.
    Sheesh.

  • How to view the source code for Native Method

    hi
    i am using some native methods in to my code ;
    can anybody tell me how to view the source code for the same ;
    nik

    Buy/acquire a C/C++/assembly code disassembler and run the shared library through it.

  • How to get the source code of Java Concurrent Program?

    Hi,
    How to get the source code of Java Concurrent Program?
    Example
    Programe Name:Format Payment Instructions
    Executable:Format Payment Instructions
    Execution File Name:FDExtractAndFormatting
    Execution File Path:oracle.apps.iby.scheduler
    Thanks in advance,
    Senthil

    Go on Unix box at $JAVA_TOP/oracle/apps/iby/scheduler
    You will get class file FDExtractAndFormatting.
    Decompile it to get source code.
    Thanks, Avaneesh

  • How to display the 'language code' for language dependent 'Short text' ?

    Hi,
    I am new to BW.
    Can somebody help me with the following issue?
    I have an attribute 'Material category description'  and I chose short text exists and made it language dependent. I had loaded the master data successfully.
    Now I want to know how to check the 'language code' for this material category description. When I display the data, will the language code display by defalult?
    I had checked the text table using SE11
    It displays the following fields over there.
    /BIC/TS1_MCT_DS   [  /BIC/TS1(InfoObject name)  ]
    LANGU
    TXTSH
    I appreciate your help!
    Thank you
    Sekhar

    Dinesh,
    I went to RSD1 -> info-object -> Master Data/text tab. It shows my language selections there (Short text selected, language time dependent etc.) with everything grayed out.
    In SE16, I could display the data in the following format.
    /BIC/ST_PRID                TXTSH                 TXTMD
    P01                                   umbrella                 rainyday
    P02                                  tent                         waterproof
    etc.
    I want to see the 'language code' as one of the columns in this table.
    Can you help me do that?
    Thank you,
    Sekhar

Maybe you are looking for