This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Version Test  RSS feed

 
David Garratt
Ranch Hand
Posts: 216
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application is written to use and require version 5 of the JRE. I know the sytax of the java command to test the version number being run, but I get the impression that if someone with say version 1.4 of the JRE tries to run the compiled java class (jar) of my application it will not be able to run it, hence the version check never gets executed. Am I doing something wrong or should I be testing the java version from the command/batch file thats starts the application. The application is a swing based local app.

Thanks

Dave
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm grappling with the same issue.

I am thinking that my main class should be a class that merely checks the system requirements and that I should compile this class to have a .class compatibility to be as old as possible. This main class will either fail and will display an alert to the user telling them what's wrong or will succeed and call an entry point into the rest of the program.

I am thinking that the rest of my classes should be compiled to be compatible with version 5.0 of the JRE.

Kaydell
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Kaydell suggests makes good sense, if that's what you need to do.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
What Kaydell suggests makes good sense, if that's what you need to do.


I concur, except that I have begun to write checks like this into even the simplest programs, and think that's what everyone needs to do:

Line 88-108 of my main() class currently read ....



and I will check versioning as soon as I learn the syntax of
There are elses to match the if's thowing Exceptions if conditions are not met.
[ June 11, 2007: Message edited by: Nicholas Jordan ]
 
David Garratt
Ranch Hand
Posts: 216
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a shame that I will have to do it this way as it probably means I need a separate project in Eclipse to test the version, otherwise each time it rebuilds the project it will recompile using jre 1.6 code.
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It's a shame that I will have to do it this way as it probably means I need a separate project in Eclipse to test the version...


Would it help to use Ant? I don't know if it would help in this case, I've just read that in general that Ant can script the build process.

Kaydell
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!