1

My java application requires users to have Java 7 installed. However, if they don't, nothing is displayed or returned to the user unless they started the application from the console. The app simply terminates.
How would I generate a popup displaying a link to the correct version of Java in the case that the user doesn't have the correct one already?

Thanks for any help

Bit Fracture
  • 651
  • 1
  • 9
  • 24

1 Answers1

2

You can use System.getProperty("java.version") to get the java version in a program compiled for all version . You can then make this program launch your main application/game otherwise redirect user to install JRE 7.

The correct way to do this would be to verify it during game installation as well as during launch.

Your launcher should be compiled in lowest JDK version possible for it, like ,

javac file.java -source 1.3

If possible keep your launcher as .bat/.sh file so you can be sure that launcher would not fail if java is missing

see this for example ,

Check if JAVA_HOME is present in environment using batch script

Community
  • 1
  • 1
Avinash Singh
  • 3,421
  • 2
  • 20
  • 21
  • What you are saying is that I need one program to launch the next program after checking the java version? I will try this out. If it works, I will mark your answer as right. Thanks! – Bit Fracture Mar 04 '13 at 13:52
  • Can't figure out how to make net beans use anything other than JDK7. – Bit Fracture Mar 04 '13 at 14:06
  • You should probably check the option of using bat file I mentioned my answer , bat file is guaranteed to run on windows machine. You can verify that Java is installed with jre7 in bat file and launch your program. – Avinash Singh Mar 04 '13 at 18:38
  • The problem is, this app needs to be multiplatform and I don't want to make a different batch for each. Do you see my dilemma? – Bit Fracture Mar 04 '13 at 23:56
  • I really just need to know what I change in order to compile the program correctly using net beans. Thank you for the help though. – Bit Fracture Mar 05 '13 at 23:06
  • Have a look into this if it helps , http://stackoverflow.com/questions/9290848/how-to-set-a-java-compiler-in-netbeans – Avinash Singh Mar 06 '13 at 00:21