0

I made a desktop application with swing gui using jdk 19. It parses the metadata of the files and then moves the files from a specific folder to a shared drive (Checks if the necessary directories exist and if not, then creates them and copies files into them). When I run the code in IDEA, everything works as it should. But when I create an executable jar, I run the application, set the same parameters as in IDEA and get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.nio.file.FileSystemException: V:\!РОЛИКИ\Москва Хорошо\Test\2023\14.01: Unable to determine if root directory exists
        at gui.GUITest$1.actionPerformed(GUITest.java:52)
        at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
        at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
        at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
        at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
        at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
        at java.desktop/java.awt.Component.processMouseEvent(Component.java:6620)
        at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
        at java.desktop/java.awt.Component.processEvent(Component.java:6385)
        at java.desktop/java.awt.Container.processEvent(Container.java:2266)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4995)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4827)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.nio.file.FileSystemException: V:\!РОЛИКИ\Москва Хорошо\Test\2023\14.01: Unable to determine if root directory exists
        at java.base/java.nio.file.Files.createDirectories(Files.java:782)
        at core.Autosort.moveVideoToServer(Autosort.java:66)
        at core.Autosort.VLCjAutosort(Autosort.java:53)
        at core.Autosort.sortFiles(Autosort.java:31)
        at gui.GUITest$1.actionPerformed(GUITest.java:48)

I have no idea whats wrong with my app. What should I do to get the same result from executable jar as in IDEA? I googled that the reason might be in Windows SMB, but then why does the application work correctly if you run it from IDEA?

  • Put a breakpoint in `createDirectories`, step through it and see what the problem is. – tgdavies Jan 13 '23 at 22:37
  • I tried to debug but when i run the jar file in IDK the program runs without errors. This gave me the idea that the cause of the error is not in the code, but in how I run the application. I ran the app via command line with admin rights (win 10) and got this error. But when I ran it in the same way as a local user (without administrator rights), the program worked as it should. I don't know why I can't run as administrator and what is the reason, but now the application is working, so I'm satisfied. but your answer made me look with what parameters the application is launched in the idea) – danilasar Jan 14 '23 at 20:49

1 Answers1

0

Maybe you can try with the command line: C:\jdk1.9\bin\java -jar c:\myproject\myapp.jar and show us the log?

In fact, if it runs outside of IDEA, so usually nothing will be related to IDEA. And Java programs in fact didn't work well when they launched in a Unicode folder such as in a folder with East Asian or with spaces in the folders' path.