简体   繁体   中英

How to export all installed versions of Java to a text file under Windows XP

I'm looking to write a batch file I can deploy to 20-30 users that will export all of the enabled versions of Java out to a text file, which I can then pick up, and add to a troubleshooting effort we're working on.

I know that java -version will show the current version, but we're in an environment where we have multiple applications that use different versions.

Thanks, Josh

Assuming your runtimes are all in the same folder, You can grab the "JAVA_HOME" environment variable then just print a list of the folders in the parent directory of wherever it points.

However individual applications can bundle their own runtimes, which can be anywhere pretty much.

Since you reference -version though, I assume you are using it from the command line so pulling in JAVA_HOME and looking around there seems like a good place to start.

Have a look at the Java Deployment Tookit with its method getJREs(). This returns an array of currently installed Java Runtime Environments.

Please be advised, that this a JavaScript and you probably won't be able to use it from command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM