Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Java Jar file on Mac OS X

Tags:

java

macos

jar

I have a Java application that is running perfectly under windows, i go to the command line after building the project, execute the command

java -jar FileName.jar 

When i copied the project files to my Mac machine and executed the same command, i have the following error:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/sun/security/auth/module/NTSystem
    at androidchat.AndroidChatView.<init>(AndroidChatView.java:48)
    at androidchat.AndroidChatApp.startup(AndroidChatApp.java:19)
    at org.jdesktop.application.Application$1.run(Application.java:171)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:678)
    at java.awt.EventQueue.access$000(EventQueue.java:86)
    at java.awt.EventQueue$1.run(EventQueue.java:639)
    at java.awt.EventQueue$1.run(EventQueue.java:637)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:648)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: com.sun.security.auth.module.NTSystem
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

why is this happening as java is supposed to be portable no matter what the underlying OS is ?

Thanks

like image 549
AhmadAssaf Avatar asked Jan 20 '23 01:01

AhmadAssaf


1 Answers

Hey there I have seen this before see here for an explanation

Summary

The sun.* packages are not part of the supported, public interface. A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.

like image 86
Paul Whelan Avatar answered Jan 27 '23 21:01

Paul Whelan