{"id":26562040,"url":"https://github.com/nahkd123/com4j","last_synced_at":"2025-11-09T14:04:44.563Z","repository":{"id":282760781,"uuid":"949556873","full_name":"nahkd123/com4j","owner":"nahkd123","description":"Using Component Object Model (COM) in Java","archived":false,"fork":false,"pushed_at":"2025-03-23T18:13:03.000Z","size":117,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-09T14:03:41.570Z","etag":null,"topics":["component-object-model","foreign-function-and-memory-api","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nahkd123.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-16T18:07:51.000Z","updated_at":"2025-03-17T20:27:12.000Z","dependencies_parsed_at":"2025-03-16T19:48:50.276Z","dependency_job_id":"ca2d76a2-7cb1-4524-b26b-1b1ceb5bda4a","html_url":"https://github.com/nahkd123/com4j","commit_stats":null,"previous_names":["nahkd123/com4j"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nahkd123/com4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahkd123%2Fcom4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahkd123%2Fcom4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahkd123%2Fcom4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahkd123%2Fcom4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nahkd123","download_url":"https://codeload.github.com/nahkd123/com4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nahkd123%2Fcom4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283517794,"owners_count":26849048,"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","status":"online","status_checked_at":"2025-11-09T02:00:05.828Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["component-object-model","foreign-function-and-memory-api","java"],"created_at":"2025-03-22T14:19:51.725Z","updated_at":"2025-11-09T14:04:44.544Z","avatar_url":"https://github.com/nahkd123.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# COM4J\nInteracting with Component Object Model from your Java application.\n\n**[COM4J Documentations][com4j-docs]** | **~~Releases~~**\n\n\u003e [!WARNING]\n\u003e COM4J is not ready for production use. Use at your own risk.\n\n## Introduction\nCheck out [Microsoft's own documentation][ms-com-intro] for introduction to Component Object Model.\n\nThis library aims to provide COM client functionality for your Java application by using just [Foreign Function and Memory API][java-ffi], which means this library have no C++ glue code (yet). It does not support creating COM server at this moment.\n\n## Requirement\nYou must be using Java 23 or newer, since COM4J is using Foreign Memory and Function API. That's also the reason why this repository have zero C++ code!\n\n## Quick example\n### Example 1: Creating new COM object from CLSID\n```java\nComFactory com = ComFactory.instance();\n\n// This is CLSID of RealTimeStylus\n// Find more of these with https://github.com/jkerai1/CLSID-Lookup\nGuid rtsClsid = Guid.of(\"E26B366D-F998-43ce-836F-CB6D904432B0\");\nIUnknown rts = com.createFromClsid(IUnknown.class, rtsGuid);\n\n// Since we don't know what to do with RTS (it's pretty useless without extending the interface), we just release it for now.\n// Note that you MUST release IUnknown once you are done with it. Java GC will not do it for you.\nrts.Release();\n```\n\n### Example 2: Creating new COM object from instantiating Java object\n```java\n// You must use public modifier for your interface and implementation for now\n// If you want to create COM object from CLSID, you must provide IID through\n// @ComInterface annotation.\n// @ComInterface(\"IID-HERE\")\npublic abstract class IMyComObject extends IUnknown {\n\tpublic MyComObject(MemorySegment comPtr, Runnable destroyCallback) {\n\t\tsuper(comPtr, destroyCallback);\n\t}\n\n\t// You must use public modifier for methods annotated with @ComMethod for now\n\t@ComMethod(index = 3)\n\tpublic abstract void coolMethod(int msg);\n}\n\npublic class MyComObject extends IMyComObject {\n\tpublic MyComObject(MemorySegment comPtr, Runnable destroyCallback) {\n\t\tsuper(comPtr, destroyCallback);\n\t}\n\n\t@Override\n\tpublic void coolMethod(int msg) {\n\t\tSystem.out.println(msg);\n\t}\n}\n\nComFactory com = ComFactory.instance();\nIMyComObject obj = com.createJava(IMyComObject.class, MyComObject::new);\nobj.coolMethod(42);\n\n// Wrap from COM object pointer\nIMyComObject wrapped = com.wrap(obj.getComPointer(), IMyComObject.class);\nwrapped.coolMethod(727);\nwrapped.Release();\n\n// We don't call obj.Release() here because our COM to Java wrapper already\n// released it.\n```\n\n\u003e [!NOTE]\n\u003e You must always release COM object once you are done with it. Java GC will not garbage collect your COM objects.\n\n## License\nMIT License.\n\n---\n[com4j-docs]: ./docs/index.md\n[ms-com-intro]: https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal\n[java-ffi]: https://dev.java/learn/ffm/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahkd123%2Fcom4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnahkd123%2Fcom4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahkd123%2Fcom4j/lists"}