Check java on users PC and give message

The following code has been written with Java 1.4 and works great, but if a user has Java 1.3 they get an error message and if a user has Java 1.2 nothing happens at all. Is there a way to check if the user is using a version older than 1.4 and if so pop up a message telling them they need to download a newer version of Java?
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("/ST_Migration/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

Well, if you don't want to use Package.isCompatibleWith and the version numbers will always be of the form x.y where y is at most one digit, you can use Double.parseDouble() and then compare the numbers. Otherwise you need to write a method of your own.

Similar Messages

  • *when we use at user -command and give smaple code fro at user-command*

    Hi experts,
    i am new to abap can any body tell me when we use AT USER-COMMAND and give a sample code for that.
    point will be rewarded.
    thanks.

    Hi,
    AT USER-COMMAND  is a list Event.This Event is triggered when user make an action on the Application Toolber Or Menubar.
    Here is the Program.
    START-OF-SELECTION.
      SET PF-STATUS 'TEST'.
      WRITE:  'Basic list, SY-LSIND =', sy-lsind.
    AT LINE-SELECTION.
      WRITE:  'LINE-SELECTION, SY-LSIND =', sy-lsind.
    AT USER-COMMAND.
      CASE sy-ucomm.
        WHEN 'TEST'.
          WRITE:  'TEST, SY-LSIND =', sy-lsind.
      ENDCASE.
    This program uses a status TEST, defined in the Menu Painter.
    Function key F5 has the function code TEST and the text Test for demo.
    Function code TEST is entered in the List menu.
    The function codes PICK and TEST are assigned to pushbuttons.
    The user can trigger the AT USER-COMMAND event either by pressing F5 , or by choosing List -> Test for demo, or by choosing the pushbutton 'Test for demo'.The user can trigger the AT LINE-SELECTION event by selecting a line.
    Hopr This Will help You.
    Regards,
    Sujit

  • How do you check what your user ID and password is?

    hey, anyone know how for me to find out my user id and password? I need them to start up my mail account and to download a program. I called apple but they said to either ask here or I'd have to extend my phone support, and thats too expensive for me right now, so I'm hoping somone here can tell me, thank you.
    ~Cole

    If you are accessing a mail account provided by your ISP, you should have been given an opportunity to set these when you signed up; if not, contact the ISP. If you are accessing a different email account, use the name or email address and password that you used when you signed up for it.
    If you are prompted for a password before installing an application or in the Finder, provide the username and password you used when you initially set up the computer.
    (17368)

  • User Exit and Error message creation at Delivery

    Dear Friends,
    I am capturing the penal rates and the amount received against the penal rates from the customer in the Z table.If the penal rates and the amount received from the customer is not matching the system should not allow to save the delivery and trigger an error message.
    Can sombody let me know the user exit I need to use and how to define the error message.
    Thanks
    Isaac

    Hi,
    Check SAP Note 415716 - User exits in delivery processing. With this note you could know that you must be careful with the error messages in some userexits for delivery.
    Regards,
    Eduardo

  • Java mail Gmail send and receive messages

    Dear All
    can any body send me java mail api TESTED code for send and receive gmail messages. There are may sample code on net are available but I am failed to find solution. Please help
    I will be very thank full to you
    regards
    Aamir

    No. This is not a free coding service. It is a user to user forum. The general idea is that you ask questions about code you have already written. If you want tested code you generally have to pay for it. Locking this thread, for later deletion.

  • I am trying to turn off find my phone but the phone freezes and give message time out

    I am having problems with an Iphone 4 which i got secoundhand but when i try to connect to itunes i get the message "Turn off find my phone"I have given this a try but the phone just freezes and then puts the message up "Time out took to long".

    Hi newquaysimon,
    Unless you have the Apple ID and password used to set up this iPhone, you may need to contact the original owner to turn off Find My iPhone/Activation Lock. You may find the following articles helpful:
    iCloud: Remove your device from Find My iPhone
    http://support.apple.com/kb/ph2702
    iCloud: Find My iPhone Activation Lock in iOS 7
    http://support.apple.com/kb/ht5818
    Regards,
    - Brenden

  • My first I pad is stopped and gives message to contact with I tunes

    What to do to recover my I pad 2 which giving message of stopping  and advise  to contact I tunes

    Start iTunes on your computer, make sure it is version 11.1 or later. Connect your iPhone.

  • HT4623 After getting message on my iPhone 4S to update to IOS6, I proceeded, it states my phone is up to date.  However, when attempting to sync with my mac, Itunes does not recognize my device any longer and gives message that I must update Itunes.  Did

    Received a prompt to update my IPhone 4S to IOS6.  I did this from phone.  Then when syncing with my Mac/Itunes, it states my software is not up to date and I need to install new version of Itunes.  I did this and it still is not recognizing my iPhone when syncing to ITunes.  Also no longer can access mail as it states my Mac software is not up to date???  Help. 

    Which OS X version is your Mac running and which iTunes version is currently installed?

  • Printer (Photosmart c4680) works but is very SLOW and gives message ":Sending print data".

    Tttle says it all. This is a fairly new printer. Using genuine HP ink.

    If printer is in warranty, contact HP tech support for possible replacement.
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • Firefox won't start and give message "De verbinding werd geherintialiseerd.

    I tried first to fix the problem by resetting Firefox.
    When the trouble continue I install the version 23.
    This not working and the popup still appaers "De verbinding werd geherintialiseerd".
    I can't get on internet with Firefox.
    On Internet Explorer, from where I've contacted you, there's no problem, but I prefer Firefox.
    Could you help me?
    In the other case I must use IE.
    Thanks!
    Grtz
    Fred Guldenaar

    hello fred, often such issues are caused by a firewall/security software which doesn't recognize & therefore blocks firefox: [[Fix problems connecting to websites after updating Firefox]]

  • Please check out my website and give me feedback

    Hey you iWeb Jedi's -- please check out my web page and give me your opinions -- especially you Star Trek fans out there.
    http://summerstormpictures.com
    One problem I'm having is find the perfect streaming settings for the movies. I did check them on a fast Windows machine and on a brand new Mac at the local CompUSA store. Things worked well on their very fast Internet connection but the longer concept video didn't seem to want to stream. I'm almost thinking to grab some JumpCut or YouTube code and insert it just to get it to work. I know this will put their logos in but I'm just not sure what to do.
    One thing I'm aware of and something I did do on purpose is that I made the background images very large -- to accomodate those wealthy folks with the very big, very wide monitors. I wanted never to run out of background "virtual" world no matter how big one stretched the browser window. Also, the necessity to scroll was intentional. Let me know if this is too annoying.
    Appreciate any expert helpful comments and feedback on improvements.
    No I won't update to 10.4.9!   Mac OS X (10.4.8)   I said no!

    As a teacher of marketing & multimedia presentation design, Garr Reynolds says at his site: "Design is a big, big deal. We all have a responsibility to understand its potential and its power. You do not need to be a designer — but you do need to become more design sensitive or 'design mindful'."
    In particular, according to another experienced designer: "Color should be used in the same way that type size is used: to emphasize importance, not decorate a page."
    Reynolds' page about why design matters is worth reading...
    http://www.garrreynolds.com/Design/whydesign.html
    Also this about graphic design fundamentals...
    http://www.garrreynolds.com/Design/basics.html

  • How to add a new user property and then retrieve it  from a portlet

    Trying to add a user property and then retrieve it form a remote web service?
    Add a user property and map it
    1. Create a property2. Go to Global Object Property Map3. Go to users, edit and select the new property.4. Go to User Profile Manager5. For portlets, go to the "Position Information" section and add it. (for the purpose of this test, add it to the profile section as well)6. Under the "User Profile Manager" go to the "User Information - Property Map" step in the wizard and 7. Go to the "User Information Attribute" and add the property.8. Click on the pencil to the right of it and give it a name (The name is what's going to appear in the list of user information under the portlet web service)9. Click finish10. Now create/edit the web service for the portlet from which you want to displays user properties. 11. Under the "User Information", click "add existing user Info" and select the property you want.12. From the portal toolbar, edit the user profile under "My Account" and then "Edit user Profile" and give the new property a value. 13. Test code below: ================================in C# IPortletContext context = PortletContextFactory.CreatePortletContext(Request,Response);IPortletRequest portletRequest = context.GetRequest();System.Collections.IDictionary UserInfoVariables = portletRequest.GetSettingCollection(SettingType.UserInfo);System.Collections.IDictionaryEnumerator UserInfo = UserInfoVariables.GetEnumerator();
    while(UserInfo.MoveNext()){   //to display in a listbox   ListBox1.ClearSelection();   ListBox1.Items.Add(UserInfo.Key.ToString() + ": " + UserInfo.Value);}===========================in ASP: <%Dim objSettings, dUserInfo, sEmpIDSet objSettings = Server.CreateObject("GSServices.Settings") ' get the user info settings, get employee ID from user infoSet dUserInfo = objSettings.GetUserInfoSettings
    for each item in dUserInfo response.Write "<BR>" & item & ": " & dUserInfo(item)next%>

    IPortletContext portletContext = PortletContextFactory.createPortletContext(req, res);
    IPortletRequest portletReq = portletContext.getRequest();
    String value = portletReq.getSettingValue(SettingType.Portlet,settingName);

  • False "Invalid User Name or PAssword" message

    Trying to restart my iMac with another user logged in I get a dialog telling me so and that I therefore need to enter an admin user name and password. When I do so I get "Invalid User name and Password" message even though the user name and password are correct admin's. I even changed them and the same thing happens. What's up?
    Thanks for any help.

    You may have the 'Loss of admin privileges syndrome'. The warning may not mean . the password is invalid but that it is not for what is now an admin. I and many others have had this from Leopard.
    Try this, even if you have not enabled root do so now only to disable it after the exercise.
    Insert the install DVD in any user. Restart holding down the 'c' key. Wait whilst the machine boots from the DVD. START (only) the install. When you have selected a language, do not proceed to install but pick fro one of the top menus the option in (utilities?) to re set password.
    Choose to re set the root password. Think of a good long password with upper/ lower case letters/numbers/ and Shift+top line normal kb characters such as $.
    Note said PW. Now choose from the top menus to reboot and reboot from HD. Remove DVD and login to root using PW just set.
    In root go into System Preferences, choose accounts pane. Unlock the lock icon using if need be the root id and root PW. Highlight the 'errant' admin. Tick the little square box marked 'allow to administer computer, if it is not already ticked. If you have more than one admin (a good idea to have a reserve, admins can go wrong) repeat the 'tick' process with each.
    Log out of root and into a normal admin. Go to directory services and you should find in the top menu and option to disable root. You did just enable it. Disable it.
    My recived wisdom is it is better to have a root that has been enabled>> passworded>> disabled, than have a default of a disabled unpassworded root. It is worst to have a continuously enabled.
    You now have an admin enabled to admin. If you still have a problem it may well be an invalid password. So come back.
    This problem and the one of an (apparent) comnplete los of the admin account are plagueing these forums. If you hav not already done so upgrade to 10.5.2. Make sure you repair permissions before and after aqnd remove haxies first etc.

  • Hi,  Trying to log in with my user id and password at iocbc but was not able to access. Problem message shown : Applet not initialised or may not be supported. Please refresh the page or check the browser setting  Anyone can advise? or i need to download?

    Hi,
    i have the same problem?
    Trying to log in with my user id and password at iocbc but was not able to access.
    Problem message shown : Applet not initialised or may not be supported. Please refresh the page or check the browser setting
    Anyone can advise?

    You need to install Java for your Mac OS version, and/or make sure it's enabled in the Java Preferences application and your browser's preferences.

  • A login webpage gives the message "This script requires that jquery.js be loaded first." then will not show the user ID and password login boxes. How can this be corrected?

    A login webpage gives the message "This script requires that jquery.js be loaded first." then will not show the user ID and password login boxes. How can this be corrected?

    That message is listed in two scripts on the bank's site. One function that can display the message is named PhotoRotator and the other is named PromoRotator. However, I can't seem to trigger the error myself.
    If you have any add-ons that alter the page, such as ad blockers, try creating an exception for these sites and see whether that helps:
    www.northrim.com<br>
    www.northrimbankonline.com
    You also could try this logon page: https://www.northrimbankonline.com/onlineserv/HB/Signon.cgi
    (''Obviously you should be cautious about links offered on public forums to ensure you are not being phished! Check them out carefully before entering your username and password.'')

Maybe you are looking for

  • Error when starting Bex analyzer

    Hi All! We have a world wide BW-SEM application. In one country they get the following error message when starting Bex analyzer: <install error> Missing ActiveX component: Business Explorer Global Services Does anyone have a hint on what to do? Thank

  • How to set vertical line in SAPScript

    Dear All, I have to set vertical line at a particular position of SAPScript. Here the lines are of varying length. Can you suggest how to do that? Line 1......................            | Vertical Line Line 2.........................         | Verti

  • Problem with the same name of an attribut

    Hi! I want to extract my xml-file. it looks like this,but this is only a section of my file: <inspMSMast id="900003592">           <bmTyp>MS-Mast</bmTyp>           <dsVersion>1</dsVersion>           <erfasser>Leitgeb Gerhard</erfasser>           <erf

  • How to make an editable bulleted list with multiple lines and custom bullets?

    How do I create an editable bulleted list in Acrobat Pro? I've figured out how to add text fields with multiple lines, and how to add a list box, but I don't see the check box for multiple lines in the list box or how to add bullet points. Can someon

  • HRFORMS - print program error

    Hi all, I have developed a HR FORM for printing the employee remuneration statement. In that, i have designed the layout using Adobe form and activated this form. But when i try to activate the HR FORM, it returns the following error. "Print program