2012-01-18 10 views
6

की जांच के लिए जावा कोड लिख सकते हैं मूल रूप से, मुझे अपने स्थानीय रूप से स्थापित इंटरनेट एक्सप्लोरर के संस्करण का पता लगाने के लिए बस एक साधारण जावा प्रोग्राम लिखना होगा।क्या आप अपने स्थानीय इंटरनेट एक्सप्लोरर के संस्करण

जावास्क्रिप्ट कोड है, लेकिन यह आपके ब्राउज़र के भीतर चलता है। मैं जो चाहता हूं वह कुछ कोड है:

public class VersionTest 
{ 
    public static void main(String[] args) 
    { System.out.println("you IE Version is:" + getIEVersion()); 
    } 

    public static String getIEVersion() 
    { //implementation that goes out and find the version of my locally installed IE 
    } 
} 

मैं यह कैसे कर सकता हूं? धन्यवाद

+1

संभव डुप्लिकेट (http://stackoverflow.com/questions/8916924/how-to- [जावा में इंटरनेट एक्सप्लोरर के संस्करण की जांच करने के लिए कैसे] चेक-इंटरनेट-एक्सप्लोरर-संस्करण-इन-जावा) –

+2

@ टोमाज़्नुक्यूविचज़: मैं असहमत हूं। यह वास्तव में एक असली सवाल है। –

+1

@EdwardThomson मैं सहमत हूं, हालांकि ओपी को फिर से थोड़ा संशोधित संस्करण पूछने के बजाय मूल प्रश्नों को ठीक करने के लिए सीखना है –

उत्तर

4

आप संस्करण के लिए Internet Explorer Registry Entry का उपयोग कर सकते हैं। आप Runtime कक्षा का उपयोग कर जावा से Reg Query निष्पादित कर सकते हैं। रेग क्वेरी विंडोज़ में रजिस्ट्री प्रविष्टियों को क्वेरी करने के लिए एक कमांड लाइन उपकरण है।

Process p = Runtime.getRuntime().exec("reg query \"HKLM\\Software\\Microsoft\\Internet Explorer\" /v Version"); 

पूरा कोड:

ArrayList<String> output = new ArrayList<String>() 
Process p = Runtime.getRuntime().exec("reg query \"HKLM\\Software\\Microsoft\\Internet Explorer\" /v Version"); 
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()),8*1024); 
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())) 
String s = null; 
System.out.println("Here is the standard output of the command:\n"); 
while ((s = stdInput.readLine()) != null) 
output.add(s) 

String internet_explorer_value = (output.get(2)); 
String version = internet_explorer_value.trim().split(" ")[2]; 
System.out.println(version); 

आउटपुट = मेरी कमांड प्रॉम्प्ट पर reg query की 9.0.8112.16421

आउटपुट

HKEY_LOCAL_MACHINE \ सॉफ्टवेयर \ Microsoft \ Internet Explorer को

संस्करण REG_SZ 9.0.8112.16421

2

रजिस्ट्री प्रविष्टि आप देख रहे हैं पर है:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version 

कैसे आप जावा में रजिस्ट्री प्रविष्टियों को पढ़ने करते हैं? Go read this Stack Overflow question.

2
private String getBrowserType(String currValue){ 
String browser = new String(""); 
String version = new String(""); 
if(currValue != null){ 
if((currValue.indexOf("MSIE") == -1) && (currValue.indexOf("msie") == -1)){ 
browser = "NS"; 
int verPos = currValue.indexOf("/"); 
if(verPos != -1) 
version = currValue.substring(verPos+1,verPos + 5); 
} 
else{ 
browser = "IE"; 
String tempStr = currValue.substring(currValue.indexOf("MSIE"),currValue.length()); 
version = tempStr.substring(4,tempStr.indexOf(";")); 

} 

} 
System.out.println(" now browser type is " + browser +" " + version); 

return browser + " " + version; 

} 

Source

की
+1

कोड के लिए धन्यवाद –

संबंधित मुद्दे