# Report System and Environment Diagnostics at Runtime

**URL:** <https://discourse.processing.org/t/report-system-and-environment-diagnostics-at-runtime/47384>\
**Category:** Processing\
**Created:** [October 16, 2025, 8:28pm UTC](https://discourse.processing.org/t/report-system-and-environment-diagnostics-at-runtime/47384 "2025-10-16T20:28:21Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 17, 2025, 5:46pm UTC](https://discourse.processing.org/t/report-system-and-environment-diagnostics-at-runtime/47384/6 "2025-10-17T17:46:58Z")

</div>

> [@glv](#):
>
> It will certainly require more work and updates!

I originally started this to determine which version of Processing was being used in VS Code when I changed the _settings.json_ file to different versions.

And somehow that got missed!

VS Code for Processing _settings.json_ file:

```auto
{
    "astyle-format.args": "--style=whitesmith --indent=tab=4 --indent=spaces=4",
    "astyle-format.path": "\"D:\\Program Portable\\AStyle\\bin\\astyle.exe\"",
    "processing.version": "4.4.7",
    "[Processing]": {
        
    },
    "[jsonc]": {
        
        "editor.quickSuggestions": {
            "strings": true
        },
        "editor.suggest.insertMode": "replace"
    },
    "files.associations": {
        "*.pde": "cpp"
    }
}

```

Processing code to report version number:

```processing

//==============================================================================
// TITLE: Report Location of Processing Core for Version Number
//------------------------------------------------------------------------------
// DESCRIPTION:
// This sketch demonstrates two cross-platform methods for reliably locating
// the file path of the Processing core library (core.jar) using the
// ProtectionDomain of the PApplet class.
//
// AUTHOR: glv
// DATE: 2025-10-17
// VERSION: 1.0.2
//
// REFERENCE:
// https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file
//==============================================================================

import processing.core.PApplet; // Import is implicit but good practice
import java.io.File; // Necessary for the File object
import java.net.URI; // Necessary for the URI object

void setup()
    {
    // Get Processing version path and version from core.jar
    getVersion_1();
    println();
    getVersion_2();

    // Stop the sketch
    exit();
    }

void draw()
    {
    }

void getVersion_1()
    {
    String path = "Error: Could not retrieve path";

    //Get Processing Folder Path()

    try
        {
        path = processing.core.PApplet.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();;
        }
    catch (Exception e)
        {
        println("Error: Could not retrieve path");
        }

    // Extract core version

    int lastSlashIndex = path.lastIndexOf('/'); //For Windows
    String lastElement = "Extraction Failed";

    if (lastSlashIndex != -1)
        {
        lastElement = path.substring(lastSlashIndex + 1);
        }

    // Print the result to the console
    println("Path:");
    println(path);
    println("Core:");
    println(lastElement);
    }

void getVersion_2()
    {
    String path = "Error: Could not retrieve path";

    try
        {
        URI coreURI = PApplet.class.getProtectionDomain().getCodeSource().getLocation().toURI();
        File coreFile = new File(coreURI);
        path = coreFile.getAbsolutePath();
        }
    catch (Exception e)
        {
        // Catches errors related to URI conversion

        println("An error occurred while finding the path:");
        e.printStackTrace();
        }

    // Extract core version

    int lastSlashIndex = path.lastIndexOf('\\'); // This is different than the other version!
    String lastElement = "Extraction Failed";

    if (lastSlashIndex != -1)
        {
        lastElement = path.substring(lastSlashIndex + 1);
        }

    // Print the result to the console
    println("Path:");
    println(path);
    println("Core:");
    println(lastElement);
    }

```

The above worked and this is the workflow:

- Change version number in _settings.json_ and save the file!
- Run the Processing sketch
- Read report in the console.

This pops up if the version entered is not found:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/8/b8cee5a8c53741dca1256141a96f505d3b50ca77.png)

Subsequent runs of the code use the last version that was used but the _settings.json_ remains unchanged.

I was also sorting out issues related to this and was hoping to find libraries being used _behind the scenes_:  
_[Error: The package “javax.xml.bind” does not exist. You might be missing a library - #8 by glv](https://discourse.processing.org/t/error-the-package-javax-xml-bind-does-not-exist-you-might-be-missing-a-library/47360/8)_  
That is still a work in progress…

`:)`

---

_[View the full topic](https://discourse.processing.org/t/report-system-and-environment-diagnostics-at-runtime/47384)._
