# Successfully run Samples/JavaKitSampleApp on Windows

**URL:** <https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387>\
**Category:** Java interoperability\
**Created:** [September 26, 2025, 9:15am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387 "2025-09-26T09:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayman-zhao](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rayman-zhao/32/42676_2.png) [@rayman-zhao](https://forums.swift.org/u/rayman-zhao)\
**Post date:** [September 26, 2025, 9:15am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/1 "2025-09-26T09:15:31Z")

</div>

Thanks swift-java project, it makes a new way to share code between Java and Swift.

java -cp .build/plugins/outputs/javakitsampleapp/JavaKitExample/destination/JavaCompilerPlugin/Java "-Djava.library.path=.build/debug" com.example.swift.JavaKitSampleMain  
WARNING: A restricted method in java.lang.System has been called  
WARNING: java.lang.System::loadLibrary has been called by com.example.swift.HelloSwift in an unnamed module (file:/D:/repos/test/swift-java/Samples/JavaKitSampleApp/.build/plugins/outputs/javakitsampleapp/JavaKitExample/destination/JavaCompilerPlugin/Java/)  
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module  
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Hello from Swift!  
And hello back from Java! You passed me 42  
Swift got back 3.14159 from Java  
We expect the above value to be the initial value, 3.14159  
Updating Java field value to something different  
And hello back from Java! You passed me 17  
Swift got back updated 2.71828 from Java  
Swift created a new Java instance with the value 3.14159  
Hello to Java  
Salutations, Swift ?? How's it going  
And hello back from a ??-collected language! You passed me 42  
Running a JavaPredicate from swift 3 \< 10 = true  
Converting doubles to strings: ["3.14159", "2.71828"]  
Hello from the subclass!  
Salutations, Swift  
Salutations, Hello from Swift  
Caught Java error: java.lang.Exception: I am an error  
Optional text = Optional(SwiftJava.JavaString)  
Optional string value = Optional("")  
Optional text function returned Optional(SwiftJava.JavaString)  
Optional double function returned Optional(2.0)  
Optional long function returned Optional(21)  
sayHello(17, 25) = 425

I found major problem when building is about Windows file path (the drive name, the separtor ; etc). I noticed there are some Windows compiler conditions in SwiftJavaTool already.

I wonder if there a plan to support Windows release?

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [September 28, 2025, 6:52am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/2 "2025-09-28T06:52:52Z")

</div>

Feel free to report issues and send in pull requests but currently we are not focused on Windows support, but overall it would be good to support in the future.

Pull requests would be most welcome, thank you.

---

<div class="post-metadata">

**Author:** ![rayman-zhao](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rayman-zhao/32/42676_2.png) [@rayman-zhao](https://forums.swift.org/u/rayman-zhao)\
**Post date:** [September 29, 2025, 6:42am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/3 "2025-09-29T06:42:26Z")

</div>

Thank you for kind welcome. I definitely will provide PR once comfortable with my changes.

Besides, one problem I have is a dependency Swift package has interoperabilityMode(.Cxx), so that cause all targets set interoperabilityMode(.Cxx) too. That will cause error:

macro expansion @JavaImplementation:2:6: error: method cannot be marked '@\_cdecl' because the type of the parameter 1 cannot be represented in Objective-C  
`- D:\repos\test\swift-java\Samples\JavaKitSampleApp\Sources\JavaKitExample\JavaKitExample.swift:125:2: note: expanded code originates here 22 | } 23 | 24 | @JavaImplementation("com.example.swift.HelloSwift") | `- note: in expansion of macro 'JavaImplementation' on extension of class 'HelloSwift' here  
25 | extension HelloSwift: HelloSwiftNativeMethods {  
26 | @JavaMethod  
:  
123 | throw SwiftWrappedError.message(message)  
124 | }  
125 | }  
+--- macro expansion @JavaImplementation ---------------------------  
| 1 | @_cdecl("Java\_com\_example\_swift\_HelloSwift\_sayHello")  
| 2 | func $s14JavaKitExample1\_0A14ImplementationfMp\_8sayHellofMu_(environment: UnsafeMutablePointer\<JNIEnv?\>!, thisObj: jobject, \_ i: Int32.JNIType, \_ j: Int32.JNIType) -\> Int32.JNIType {  
| | `- error: method cannot be marked '@_cdecl' because the type of the parameter 1 cannot be represented in Objective-C  
| 3 | let obj = HelloSwift(javaThis: thisObj, environment: environment!)  
| 4 | return obj.sayHello(_: Int32(fromJNI: i, in: environment!), \_: Int32(fromJNI: j, in: environment!))  
+-------------------------------------------------------------------

With limited knowledge, I’m not sure if this problem can be solved or workaround ?

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [September 29, 2025, 10:46am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/4 "2025-09-29T10:46:44Z")

</div>

Please file an issue on [GitHub - swiftlang/swift-java: Java interopability support for Swift](http://github.com/swiftlang/swift-java) – best if with a reproducer, I’m a bit unsure why the error you pasted might be happening, it’d be nice to be able to reproduce and poke at this a bit.

---

<div class="post-metadata">

**Author:** ![rayman-zhao](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rayman-zhao/32/42676_2.png) [@rayman-zhao](https://forums.swift.org/u/rayman-zhao)\
**Post date:** [December 10, 2025, 9:20am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/5 "2025-12-10T09:20:30Z")

</div>

Found a new interesting problem. The JavaKitSampleApp build/run no problem on Windows only Debug mode. On Release mode, the native methods not exported in result DLL.

I feel it possibly related to the non-public symbols strip in release build, but failed to fix it even make the protocol NativeMethods as public.

Any idea will be appreciated. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [December 10, 2025, 9:30am UTC](https://forums.swift.org/t/successfully-run-samples-javakitsampleapp-on-windows/82387/6 "2025-12-10T09:30:00Z")

</div>

Would you mind filing an issue please? Is there any additional steps to it, or just -c release building the example?
