Solved

Is there a way to auto detect java version and upgrade if under version 1.4.x??  Reason is....

Posted on 2003-12-04
9
396 Views
Last Modified: 2007-12-19
Ok I'm sure this has been an issue in the past but I havent found anything on it.
I have a simple java file that I want to run on my pc. I have created the simple installer
and everything. One problem the java file requires Java version 1.4 or greater to be installed in order to run. So is there some way or command that I can check a) that java is installed on the pc and b)check to see if below version 1.4 (and if so install/update).
Sounds simple enough but I'm alittle lost.
0
Comment
Question by:garzajd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Author Comment

by:garzajd
ID: 9876518
I'm sure it doesnt compare but the best way I can describe what I'm thinking about is this:

Think of when you are installing a new game.
After the install or during it will check for a vesrion of DirectX
If the local installed version is below 8 or isnt installed at all
it will prompt you and ask if you want to update.

Thats what I'm going for
0
 

Expert Comment

by:PistosChristou
ID: 9876658
Running "java -version" will print out the version.  You can use this text in any script you write.  Upgrading or installing a new JRE or JDK on behalf of the user may be a problem, considering they have to agree to the EULA, and that Sun requires EULA agreement on their site before downloading begins.  Therefore, you could always just detect the version, and then open up http://java.sun.com/j2se/1.4.2/download.html (or some deeper link) in their default browser if the version is too low for your liking.
0
 
LVL 1

Author Comment

by:garzajd
ID: 9877976
I know that "java -version" prints out the version,build, and everything else.
However for example I'm trying to make this into a batch file (for now)
that will read the "java -version" output and strip everything but the
1.x.x.. however I have not been able to get the output of "java -version" into
a variable or a file. I've even gone as basic to do
java -version >test.txt
but this does not work test.txt is left empty
All I really need help with is determining what version ,if any, is currently installed
on the compter - and then I can compare that to what I am looking for and
have the batch file either do routine A or B

did I make any sence?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
vzilka earned 168 total points
ID: 9878137
Can you use Java Web Start (have an http server from which users will be able to download your Java code)?
If so, check it out, as it is used to fulfill exactly what you need
0
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 166 total points
ID: 9879955
Hello Friend;

1.) What you could do is to create a batch file 1st and incode this to the batch file :

     "java -version"

2.) Then create a method that should run on the the start of the program and put
      this on the method :

     // If you have a folder then add it
     Process p = Runtime.getRuntime().exec("file.bat");

Hope it helps . . .
Javatm
0
 
LVL 4

Assisted Solution

by:nil_dib
nil_dib earned 166 total points
ID: 9880809
what we did:

String strVersion = System.getProperty("java.version");
String strRequired = "1.3.1";
            
if (strVersion.compareTo(strRequired) < 0) {
   String str = "WARNING: ....blabla .. run
           with a " +strRequired+" or higher
           version Virtual Machine!!!\nYou
           should install a new Runtime
           Environement.\nLook at
           http://java.sun.com .";

       ErrorDialog d = new ErrorDlg(str);
          d.setVisible(true);
                                    System.exit(1);


nil_dib
                  
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Android development question 2 110
Java basic valueOf question 1 51
wild fly 8 startup error 2 82
Github api to fetch the number of collaborators in a git repo 1 70
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question