{"id":15417367,"url":"https://github.com/brunoborges/wcjvm","last_synced_at":"2025-04-19T14:38:47.743Z","repository":{"id":196776423,"uuid":"697078139","full_name":"brunoborges/wcjvm","owner":"brunoborges","description":"JVM launcher inside Windows Containers in Process Isolation mode","archived":false,"fork":false,"pushed_at":"2023-11-04T18:43:20.000Z","size":36,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T08:43:39.863Z","etag":null,"topics":["containers","java","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brunoborges.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-27T02:26:56.000Z","updated_at":"2024-01-22T23:48:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"fec4a371-401e-4838-bed1-280e75668176","html_url":"https://github.com/brunoborges/wcjvm","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":0.09090909090909094,"last_synced_commit":"c78c8aadc9c85da38a65caeef19b1a0bf5485ae2"},"previous_names":["brunoborges/wcjvm"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoborges%2Fwcjvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoborges%2Fwcjvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoborges%2Fwcjvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunoborges%2Fwcjvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunoborges","download_url":"https://codeload.github.com/brunoborges/wcjvm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249715915,"owners_count":21315059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","java","windows"],"created_at":"2024-10-01T17:15:25.018Z","updated_at":"2025-04-19T14:38:47.725Z","avatar_url":"https://github.com/brunoborges.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Container JVM Launcher\n\nThis project is a proof of concept for a JVM launcher inside Windows Container.\n\n## Why\n\nThe OpenJDK HotSpot JVM is not Windows Container aware (in [_Process Isolation Mode_](https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container#process-isolation)). For this reason, the JVM will thus not be able to identify the amount of CPU and Memory given to the container. This will result in the JVM ergonomically sizing itself based on the total amount of CPU and memory of the entire Windows host. Often, this translates into a JVM crash due to insufficient memory.\n\nIntroducing... `wcjvm`.\n\n## wcjvm\n\nThe `wcjvm` command identifies the amount of CPU and Memory given to the container and will start the JVM with the appropriate parameters.\n\nIn essence, `wcjvm` is a wrapper (or a shim) of the `java` command, specifically for launching the JVM from within a Windows container.\n\n## Build\n\n`wcjvm` is a Windows native executable. It is written in .NET 7.0 and compiled with the .NET SDK. To build the project, make sure you have .NET SDK 7.0 installed. Then, run the following command:\n\n```bash\ndotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true\n```\n\nThe above command will produce a single executable file `wcjvm.exe` in the `out` folder as per the `wcjvm.csproj` configuration file.\n\n## Usage\n\nBundle `wcjvm` along with the JDK of your choice into a Windows container image. You can drop the `wcjvm.exe` command into the `bin` folder of your JDK. Then, use `wcjvm` to launch the JVM, instead of `java`.\n\nMake sure your JDK of choice is properly configured in your system path as in:\n\n```bash\nJAVA_HOME=\"C:\\Program Files\\Java\\jdk-17\"\nPATH=\"%JAVA_HOME%\\bin;%PATH%;%WCJVM_OUT%\"\n```\n\nThen, just launch the JVM:\n\n```PowerShell\nwcjvm -jar myapp.jar\n```\n\n## How it works\n\n`wcjvm` uses a combination of Windows API and .NET API to identify the amount of CPU and Memory given to the container. It then parses the JVM command line arguments, and adjust any and every necessary JVM flag to ensure it fits in the Windows container. \n\nPrimarily, it will set `-XX:ActiveProcessorCount=N` and `-XX:MaxRAM=NNN` to the appropriate values. This will right-size the JVM in terms of processor counting (and therefore GC threads, ForkJoinPool, and any other 3rd-party framework that needs this value), as well as the heap size.\n\nIt will also adjust other flags such as the GC selection. This one happens particularly because HotSpotJVM's ergonomic GC selection reads from `os::physical_memory` which does not reflect any value given to `MaxRAM`, and it is not Windows container-aware.\n\n## Known issues\n\nThe `OperatingSystemMXBean` will still report `totalMemory` as the total amount of memory of the Windows host. This is a known issue and it is not possible to fix it. However, this is not a problem because the JVM will not use more memory than the one given to the container thanks to the JVM flags set by `wcjvm`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunoborges%2Fwcjvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunoborges%2Fwcjvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunoborges%2Fwcjvm/lists"}