Results 1 to 5 of 5
  1. #1
    Basit56 is offline Member
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Default Check java version with previous versions

    Hi to all :),
    Hope you all will be fine. I want to ask if i want to check java version with previous versions how can i do it. First i'll know the java version by
    Java Code:
     String version = System.getProperty("java.version");
    Now i want to check this version with previous version. Actually i want to check in an applet that if user has less than version 1.6.0_12 then it prompts a message that you require minimum version 1.6.0_12 so how can i do it.

    Also i want to ask that i will prompt a message using JOptionPane.showMessageDialog(null,string) .Actually i want that when user click ok button the new window open containing java link to download java.How can i do it using JOptionPane.showMessageDialog or i'll use some other approach
    Thank you in advance

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Try requesting with

    Java Code:
    getAppletContext().showDocument(urlToTheDownloadsPage);
    when the OK button is clicked

  3. #3
    Basit56 is offline Member
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Question

    Hi,
    Thanks for the reply. I write this code but it is not opening new window. Can you please tell me what i am doing wrong . It didn't show any error when i am running it in NetBeans
    Java Code:
    import java.applet.*;
    import java.awt.*;
    import java.net.*;
    
    import javax.swing.JApplet;
    import javax.swing.JOptionPane;
    
    
    public class JavaVersionDisplayApplet extends JApplet {
    
       //constructor
       //public JavaVersionDisplayApplet() {
    
        public void init() {
           String version = System.getProperty("java.version");
           char major = version.charAt(0);
           System.out.println("major is " + major);
           char minor = version.charAt(2);
           System.out.println("minor version is " + minor);
           char micro = version.charAt(4);
           System.out.println("macro is " + micro);
           char update = version.charAt(6);
           System.out.print("update is " + update);
           char update1 = version.charAt(7);
           System.out.println(update1);
         
       
           if(minor < '7' ){
               JOptionPane.showMessageDialog(null," JDK version "+ version + " found but JDK 1.6 update 12 or higher " +
               "is required to run the applet." );
               //getAppletContext().showDocument(url);
               String link = "url";
               try {
                  AppletContext a = getAppletContext();
                  URL url = new URL(link);
                  a.showDocument(url,"_blank");
                  //      a.showDocument(url,"_self");
                  //      _self to open page in same window
               } catch (MalformedURLException e){
                    System.out.println(e.getMessage());
                 }
           }
       }
    }
    Thank you

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You didn't put a valid url.
    When you catch exceptions during testing do
    Java Code:
    e.printStackTrace();

  5. #5
    Basit56 is offline Member
    Join Date
    Aug 2009
    Posts
    48
    Rep Power
    0

    Default

    Hi :),
    Hope you will be fine.The code is working now actually When i try it on netbeans it was working but the page was not open. So i manually compile it then sign the jar and now it is working.

    Thank you :)

Similar Threads

  1. Java Versions
    By hiranya in forum New To Java
    Replies: 6
    Last Post: 10-27-2009, 12:42 PM
  2. Replies: 4
    Last Post: 01-01-2009, 04:21 PM
  3. Replies: 0
    Last Post: 12-13-2008, 06:21 PM
  4. Can I delete/uninstall older versions of Java?
    By LudwigKarl in forum New To Java
    Replies: 3
    Last Post: 03-19-2008, 10:23 AM
  5. Using different versions of Java
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 01-04-2008, 08:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •