It seems like the issue lies in how the keyStore file path is being resolved when running the JAR file locally on your Windows machine.
When you run the code in IntelliJ or through Jenkins on a server, the file path "classpath:MyKStoreFile.pfx" is resolved correctly because it's able to locate the file within the project's classpath. However, when you run the compiled JAR file directly from the command line using "java -jar myJar.jar", the classpath might not be resolved in the same way as in the IDE or Jenkins environment.
To resolve this issue and ensure that the keyStore file can be located when running the JAR file locally, you can try the following approach:
1. Update code to load the resource as a stream: Instead of trying to get the absolute path of the file, you can load the resource as a stream directly from the classpath. Modify line #1 as follows:
```java
InputStream inputStream = getClass().getResourceAsStream("/MyKStoreFile.pfx");
```
2. Load the keyStore from the input stream: Once you have the input stream, you can load the keyStore using it:
```java
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(inputStream, myKeyStorePassword.toCharArray());
inputStream.close();
```
3. Set the keyStore using the loaded KeyStore object:
```java
SSLContext sslContext = SSLContext.getInstance("TLS");
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.ge tDefaultAlgorithm());
keyManagerFactory.init(keyStore, myKeyStorePassword.toCharArray());
sslContext.init(keyManagerFactory.getKeyManagers() , null, null);
SSLContext.setDefault(sslContext);
```
By loading the keyStore file as a stream directly from the classpath, you ensure that it can be accessed regardless of the environment where the JAR file is executed. This approach should resolve the issue you're encountering when running the JAR file locally on your Windows machine. If you need further
help with Java assignment or any programming tasks, there are resources available online that can provide guidance and support like
ProgrammingHomeworkHelp.com.