After January 2019, businesses will need a commercial license to receive updates for Oracle Java SE products. This means that if you’re using Java in your environment, chances are that your management will need to know how many licenses to buy and how many PC has Java installed but don’t use it.
The bad news is that SCCM Software Metering cannot do a reliable job to track Java Usage since the executable file always runs on computers. The good news is that there’s a way to track Java usage using Oracle tools… but it’s not straightforward.
After searching, I found an awesome script made by Steve Jesok that do exactly what I needed. Unfortunately, the blog post is a bit old and don’t have detailed information on how to implement it.
We will guide you through the process and we’ll also provide a free report to help you track your java usage using SCCM.
Important Info
Java Usage Tracker requires a commercial license for use in production. To learn more about commercial features and how to enable them, see Oracle Java SE Advanced & Suite Products.Process Overview
Here’s a high-level process overview. It’s quite simple as the PowerShell script, configuration item and report are already created. You only have to import everything on your SCCM server.
- Download Java inventory .zip file
- Import Configuration Data in SCCM
- Modify Configuration Baseline
- Deploy Configuration Baseline
- Import Report
Download SCCM Java Inventory .zip file
I cannot say this enough, all the magic behind this solution is possible because of Steve Jesok script. Download the .zip file from the MNSCUG website or from our direct link (backup link…) and save it on your computer.
Import Java Configuration Data
Once you have downloaded the .zip file, extract it so you have a .cab file. We will use the .cab file to create a Configuration Item in SCCM.
- In the SCCM Console, go to Assets and Compliance / Compliance Settings / Configuration Items
- Right-click Configuration Items and select Import Configuration Data
- Click Add
- Select the JavaUsageTracking.cab file
- Click Next
- Click Next
- Validate and close the wizard
- The Java Logging Configuration Item has been created
- Right-click the Java Logging Configuration Item and select Properties
- By default the Configuration Item cannot run on Windows 10, select the Supported Platforms and enable Windows 10. Select Other Operating System that you want to support.
- You should also have a Java Usage Tracking Configuration Baseline created by the import process
- Right-click the baseline and select Deploy
- Click Browse and select a test collection
Java Configuration Baseline – Test and verification
We will now evaluate the Java Configuration Baseline on our test computer.
- Log on your test computer
- Open Control Panel / Configuration Manager applet
- In the Configurations tab, select the Java Usage Tracking baseline and select Evaluate
- Once Evaluate, click View Report
- The report will show Non-Compliant but this is normal
- Validate the presence of the usagetracker.properties file that has been created by the baseline. The file should be in the C:\Program Files (x86)\Java\Jre[yourversion]\lib\management folder
- The script also logs its action in the SCCM log directory – CM_JavaUsageLogging.log
- The CM_JavaUsageTracking WMI class has been created
- Launch any application that needs Java or visits any web page that needs Java.
- After a couple of minutes, you should have some data in the WMI classes. This confirms that the monitoring process is fully functioning
Collect information using Hardware Inventory
Now that our data is in WMI, we need to instruct SCCM to gather this information in its next hardware inventory cycle.
- Open the SCCM console and go to Administration \ Client Settings
- Select your Default client setting and select Properties
- Select Hardware Inventory and select Set Classes
- In the Hardware Inventory Classes window, click on Add
- Click Connect and enter the test computer name and leave the default WMI Namespace (root\cimv2)
- A list of the inventory classes will show, find CM_JavaUsageTracking, check it and click Ok
- You can leave the inventory classes in the Default Client settings or you can enable it in a custom one if you have one
- Make sure that the client setting is deployed to your test collection and initiate a Hardware Inventory from the Configuration Manager applet
- As in any Hardware Inventory cycle, you can validate that the new classes get inventoried in the InventoryAgent.Log
- The CM_JavaUsageLogging.log in the SCCM logs folder should show activity
Java Data Verification
- In the SCCM Console, right-click your test computer and select Start / Resource Explorer
- You should see the CM_JavaUsageTracking classes under Hardware
- If you are familiar with SQL, a new v_GS_CM_JavaUsagetracking view has been created
Report
Now that our Java tracking data is gathered by SCCM we have built an SSRS report to show which computer has run Java. You can download the free Asset – Java Inventory and Metering report by visiting our product page. Leave us your comments if you are using our report so that we can improve it over time.
Important Info
This report will work only if the above steps have been made. If you try to run the report without creating the Java view, the report will failShare this Post
59 Comments on “SCCM Java Inventory and Metering”
HI,
Thank you for the post! After following the steps for the first part. I ran evaluation on a test computer. I got Compliance state “error”
Evaluation Time:
6/29/2021 6:27:42 PM
Baseline Name:
Java Usage Tracking
Revision:
3
Compliance State:
Error
Non-Compliance Severity:
Critical
Description:
Java software metering. http://docs.oracle.com/javacomponents/usage-tracker/overview/index.html
There is no usagetracker.properties or CM log either. Could you please advise?
Thank you!
Does anyone know why the CM_JavaUsageTracking class won’t show up when I rt-click on my test computer and start the resource explorer?
You also needs to enter in your private information (age, sex, weight) as ths helps decide how
many calories you burrn per session.
On Sunday, the Apple Watch counted a complete of three,915 energy, in compawrison with 2,752
for the Fitbit app.
I think this is among the most vital information for me.
And i’m glad reading your article. But want to remark on some general things, The web site style is perfect, the articles
is really nice : D. Good job, cheers
“The bad news is that SCCM Software Metering cannot do a reliable job to track Java Usage since the executable file always runs on computers”
Can you please verify this? On 3 test machines so far java is installed but not running until called from another program. Once closed java closes as well. Thank you.
Asset – Java Inventory and Metering Report: What does “Null” mean in the Type (Normalized) column?
It looks like some of the Java information has leading or trailing whitespace. I edited the query in the dataset to change instances of = ‘something’ to LIKE ‘%something%’ to account for leading or trailing whitespace.
Here’s the content of the case statement I changed.
CASE WHEN CMJ.Type0 like ‘%plugin2%’ THEN ‘Applet’ WHEN CMJ.Type0 like ‘%VM Start%’ THEN ‘Java application’ WHEN CMJ.Type0 like ‘%javaws%’ THEN ‘Java Web Start’ WHEN CMJ.Type0 like ‘%denied%’ THEN ‘Denied’ ELSE ‘NULL’ END As Type,
Nice read but needing a “Commercial License” to use is complete do-do by Oracle. To have feature that’s in your free product only to enable this feature now makes it subscription based. Complete garbage.
Any thoughts on why the report would only return info on one client, it is deployed to all workstation clients? But seems to only return results for a single client.
I am relatively new to SCCM reporting and I am unsure of how to switch the Report Server URL in the free report from their generic http://sccm2012/ReportServer, to the URL for my actual server. I can’t edit the Built-in Fields, and when I go to Parameters and go to Default Values > Specify Values and enter the URL, that doesn’t work either.
For anyone who gets an error instead of a warning when looking at the component report;
You might need to change your powershell execution policy. Default policy blocks the script I used (I used the one Chris Kibble wrote). A different approach would be to sign the script before using it.
Hope this helped anyone!
Hey there. I’ve deployed the baseline as outlined in the instructions. Some machines seem to run it fine, but there are some that are coming up with an error “0x8007001 – Incorrect Function”. I am not a PS guru by any means. Any ideas what would be causing this?
Is there a way to trigger down results?
I mean, to know how many licenses you will need – you will only have to know how many apps are using java pro computer.
Now how many times it’s started.
So you should be able to filter down the whole thing and know: this computer has started java from 5 different locations, which means it will need 5 licenses.
Is there a way to accomplish this?
Hello,
Great post.
Is there a way to do an inventory also for the embedded versions of java?
Thanks alot.
EDIT: Apparently you can put the usagetracker.properties inside: %PROGRAMDATA%\Oracle\Java
With this in place also embedded java are writing to the log.
I’m still testing it but it seems to work.
Apart from that – there is a Central File System Location where you can put the usagetracker.properties and it should track ALL installed java versions (except embedded).
Why is this not used inside the script?
Cheers
EDIT2:
So after a little testing I’ve found out that you should put the usagetracker.properties
C:\ProgramData\Oracle\Java [in my environment was needed for a couple of software with embedded java]
C:\Program Files\Java\conf [is the Central File System Location for Java, it should enable logging for each installed Java version – was also needed for software which had embedded java + software which used the installed Java]
C:\Program Files\Java\JRE\Management [if you don’t use the central file system location, you can enable logging
version specific for x64 Java]
C:\Program Files (x86)\Java\JRE\Management [if you don’t use the central file system location, you can enable
logging version specific for x86 Java]
Maybe this can be helpful for someone
Cheers
Will the metering script work for OpenJDK installations such as Red Hat?
We have used this process to eliminate 95% of our Java installations and are looking to replace even more with Red Hat OpenJDK. I can see in the CM_JavaUsageLogging that it is detecting the JRE path for Red Hat and is placing the usagetracker.properties file in the correct location, but I am not seeing any usage being reported for systems that I know are using java apps or services.
For most recent news you have to visit world wide web and on web I found this web
site as a best web site for hottest updates.
To fix the null value edit the Query in report and remove the spaces before ‘ plugin’ and ‘ VM Start’ –> ‘plugin’ and ‘VM Start’
I’ve tried what you suggested but I still have null values.
Changed:
CASE WHEN CMJ.Type0 = ‘ plugin2’ THEN ‘Applet’ WHEN CMJ.Type0 = ‘ VM Start’
to
CASE WHEN CMJ.Type0 = ‘plugin2’ THEN ‘Applet’ WHEN CMJ.Type0 = ‘VM Start’
But nothing changed
The inventory and reporting is great, however all the values in the Type (Normalized) column show as NULL.
I looked in SQL and see there are values so not sure why they are not showing in the report. With Oracle now moving to a subscription model, we are trying to identify what is out that that requires the plugin since there is no replacement for this other than paying Oracle a monthly fee. Any help is appreciated. Thank you
Awesome guide. But you should have a note saying it only works for 32 bit, and that Chris Kibble’s github has the script for 64 bit.
This is great, thank you for sharing. I have everything working perfectly in my environment. My only issue is that I’m unable to get the report downloaded from the site. I hit the download button and submit my email address (tried 2 different addresses) but the report never arrives. Can someone check whether there is a problem with emailing reports?
Is there anything in this solution that could possibly trigger updates for Java products? In my test group I had one user who, without knowing I had deployed CI/CB, reported getting a UAC prompt for a Java update. Since the normal behavior is for Java updates to show up in the system tray, I found it unusual.
What part of this CI/CB could be invoking Java to update, skipping the system tray and going straight to UAC? If there is something, can it be disabled as to avoid having our users greeted with UAC to update a product that they maybe shouldn’t? Some of our users are advised to skip Java updates until a certain software vendor approves the new version. Thanks!
Has anyone had an issue running / modifying the included report?
I am getting File, interop.shdocvw.dll, has a different computed hash than specified in manifest. when i try and open to edit.
I made some modifications to the script to address some things that came up when I was testing this. Posted to GitHub for anyone who wants to steal a copy or suggest changes of their own to the community via pull requests.
https://github.com/ChrisKibble/JavaUsageTracking
Changes Implemented:
* Minor readability / Unused Variable Cleanup.
* Support for 64-bit Java.
* Fixed leading space in multiple fields.
* Fixed issues where JVM Vendor would populate blank in WMI.
* Added OverwriteUT (default $false) to always overwrite the usage tracking file.
Like Benoit, full credit out to Steve Jesok who did all of the heavy lifting on the script.
Hi Chris thanks for the update.
I was able to implement the reporting as outlined above but would love to add your improvements. The .cab has 2 RESX files and 2 XML’s. How does one go about replacing the RESX/XML’s with your powershell script?
Wait I think I found it… Do I just replace the script in the Config Item via Java Logging > Settings > Java Usage Tracking > Edit > Edit Script? Just a copy+paste situation? Since I don’t totally understand how this script arrived here, I just want to make sure that I’m not circumventing some important step by replacing that existing script.
Hi Garrett –
I think you’ve got it – you follow all steps from the original blog post here on SCD, and then just replace the existing script.
Good luck!
Chris
Chris,
Thanks for posting this. How long after running an app/web site that uses JRE should usage data be populated in the WMI classes? I’m not getting anything.
https://i.imgur.com/7c78tB5.png
https://i.imgur.com/ZB3B90f.png
Thanks
I modified the script to do detect both x86 and x64 (nothing fancy just copied the IF block and renamed the variables to distinguish x86 vs x64). I also changed the JREPath variable to include a Resolve-Path:
$JREPath_x86 = @(“C:\Program Files (x86)\Java\*”) | Resolve-Path
$JREPath_x64 = @(“C:\Program Files\Java\*”) | Resolve-Path
#Enable Java logging by enumerating the JREs from the registry
$Keys_x86 = Get-ChildItem “HKLM:\Software\WOW6432Node\JavaSoft\Java Runtime Environment”
$Keys_x64 = Get-ChildItem “HKLM:\Software\JavaSoft\Java Runtime Environment”
$JREs_x86 = $Keys_x86 | Foreach-Object {Get-ItemProperty $_.PsPath }
$JREs_x64 = $Keys_x64 | Foreach-Object {Get-ItemProperty $_.PsPath }
#Evaulate for x86 JRE installs
ForEach ($JRE_x86 in $JREs_x86) {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “Interogating JRE path $($JRE_x86.JavaHome)” -Severity 1}
$JREPath_x86 = test-path “$($JRE_x86.JavaHome)\lib\management”
if ($JREPath_x86) {
$UTProps = test-path “$($JRE_x86.JavaHome)\lib\management\usagetracker.properties”
if (-Not $UTProps) {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “Creating $($JRE_x86.JavaHome)\lib\management\usagetracker.properties” -Severity 1}
Create-UsageTrackingProps -UTPath “$($JRE_x86.JavaHome)\lib\management\usagetracker.properties”
} Else {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “$($JRE_x86.JavaHome)\lib\management\usagetracker.properties exists” -Severity 1}
}
}
}
#Evaulate for x64 JRE installs
ForEach ($JRE_x64 in $JREs_x64) {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “Interogating JRE path $($JRE_x64.JavaHome)” -Severity 1}
$JREPath_x64 = test-path “$($JRE_x64.JavaHome)\lib\management”
if ($JREPath_x64) {
$UTProps = test-path “$($JRE_x64.JavaHome)\lib\management\usagetracker.properties”
if (-Not $UTProps) {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “Creating $($JRE_x64.JavaHome)\lib\management\usagetracker.properties” -Severity 1}
Create-UsageTrackingProps -UTPath “$($JRE_x64.JavaHome)\lib\management\usagetracker.properties”
} Else {
IF ($LoggingEnable -eq $true) {Log-ScriptEvent -Value “$($JRE_x64.JavaHome)\lib\management\usagetracker.properties exists” -Severity 1}
}
}
}
Thanks SystemCenterDudes! This was a HUGE help for us!
Awesome, thank you for sharing !
Did you just replace everything between these 2 lines with your code?
#Set Variables
and
#Enumerate user profile folders from WMI
Will this track JRE usage on Server OS’s as well?
This only tracks JRE? I thought the intention was to track JDK? Am I misunderstanding something?
I did extend the powershell with “$Keys += Get-ChildItem “HKLM:\Software\JavaSoft\Java Runtime Environment”” to add x64 support.
Now it is creating the “usagetracker.properties” file in x86 & x64 \Java\jre8\lib\management, also my Client is adding java usage to the database.
Can anybody confirm?
Doesnt work with 64 bit Java for me
I believe the issue with not being able to monitor x64 is due to the powerscript only enumerating WOW6432 registry keys, so it only knows about 32bit installs of Java to be able to put the usagetracker.properties file in the correct location. The script needs to be modified to account for this. I did find this URL “https://docs.oracle.com/javacomponents/usage-tracker/overview/” which talks about a a central location but it only works for the latest versions.
Is there a list of what the compliance states mean? When i run the Evaluation and Get the report view on the test machine, I have a compliance state: Error and Non-Compliance Severity: Critical.
Check the script in the config item. It will have all the details.
Hi @ all I ogt work locally, but when I use the report Asset – Java Inventory and Metering it says ” No device found” Did I something wrong? The report sees the total number of devices, but says that no device is using Java. That’s impossible.
Thank you for the post and script, however I’m having issues getting it to run on my Windows 7 machines. Anyone else having issues?
I have tried to run it directly from Powershell on some sample machines and it appears to be choking on syntax in the script. First (of many) errors are:
You must provide a value expression on the right-hand side of the ‘+’ operator.
At line:31 char:36
I was able to figure this one out. If anyone else runs into this issue, there are extra spaces after the backtick (`) for the line breaks in lines 31-37. These extra spaces must be removed for it to run properly on Windows 7.
I removed the extra spaces and have the baseline deployed to about 65 systems but still only have 2 in the report.
Give it some time to run. Once Java is used on a machine and it checks in, it should appear on the report.
ok, have connected it to my datasource now, but the only pc that shows data is my test pc. I have confirmed the client settings are deployed to the All Workstations collection.
I have been able to get it working for Win10, but not Win7. It takes some time for the data to come in as Java has to be launched after the CM was pushed. It may take some time, so be patient with it.
Hi All, I’m just having some trouble with the report step. I get this “The report server cannot process the report or shared dataset. The shared data source ‘CM_SCD’ for the report server or SharePoint site is not valid. Browse to the server or site and select a shared data source. (rsInvalidDataSourceReference)” when I try to run it from the reports portal. Have I done something wrong?
It doesn’t appear in the list of reports in the sccm console.
Tim
I also get this error from the report, how do we fix this?
I get the same error. If I run the Report directly in the sql man. studio, it works. Does anyone know what changes we have to make to get it running?
I managed to get the report working, at least at a glance.
1. Click on dropdown of your imported report and edit in report builder.
2. In report builder, expand Datasets. Right click on the dataset and click dataset properties
3. click new dataset. Browse to the dataset on your report server. Dataset should use logged in user credentials.
4. Repeat for other datasets
5. Save report
I’m still poking around because the above process was giving me some access errors. I’m getting some null values as reported in the comments as well still.
Thank you so much for putting this together!
https://support.microsoft.com/en-gb/help/3092358/software-update-troubleshooting-and-maintenance-in-system-center-2012
This seems to work well for x86 Java but not x64. Is there a way to monitor x64 also?
Did you or anyone find a way for this to track 64 bit JAVA?
I also would like to know about this. We really need it to both track x86 and x64 JAVA.
Thanks
see chris kibbels answer to this: https://github.com/ChrisKibble/JavaUsageTracking
what answers are you referring to? I see no comments/questions/answers on the github link