MCreator crashes on start-up

Published by SebUnger on
Status
Works as designed
Issue description

Hi,

I just freshly installed MCreator for the first time but it crashes on startup:

seb@eragon:/usr/local/lib/MCreator[0]$ java -jar mcreator.jar 
[Sun Apr 08 12:47:55 NZST 2018] [Launcher] Java specification version: 1.8
[Sun Apr 08 12:47:55 NZST 2018] [Launcher] Installation path: /usr/local/lib/MCreator
[Sun Apr 08 12:47:55 NZST 2018] [Launcher] User home of MCreator: /home/seb/.mcreator/
[Sun Apr 08 12:47:55 NZST 2018] Error writing ./user/is.setup (No such file or directory)
[Sun Apr 08 12:47:55 NZST 2018] Error writing ./user/workspace/workspace.settings (No such file or directory)
[Sun Apr 08 12:47:55 NZST 2018] java.io.FileNotFoundException: ./user/workspace/workspace.settings (No such file or directory)
[Sun Apr 08 12:47:55 NZST 2018]     at java.io.FileInputStream.open0(Native Method)
[Sun Apr 08 12:47:55 NZST 2018]     at java.io.FileInputStream.open(FileInputStream.java:195)
[Sun Apr 08 12:47:55 NZST 2018]     at java.io.FileInputStream.<init>(FileInputStream.java:138)
[Sun Apr 08 12:47:55 NZST 2018]     at java.io.FileInputStream.<init>(FileInputStream.java:93)
[Sun Apr 08 12:47:55 NZST 2018]     at co.pylo.mcreator.a.f(SourceFile:1985)
[Sun Apr 08 12:47:55 NZST 2018]     at co.pylo.mcreator.Launcher.main(SourceFile:125)
[Sun Apr 08 12:47:55 NZST 2018] Error writing ./user/workspace.mcreator (No such file or directory)
[Sun Apr 08 12:47:56 NZST 2018] [WebIO] Reading from URL: https://mcreator.net/app
[Sun Apr 08 12:47:59 NZST 2018] [WebIO] Reading from URL: https://mcreator.net/app/motw
[Sun Apr 08 12:47:59 NZST 2018] [WebIO] Reading from URL: https://mcreator.net/app/news
[Sun Apr 08 12:48:00 NZST 2018] Skipping update message ...
[Sun Apr 08 12:48:00 NZST 2018] [StaticElements] Loading default Minecraft elements
[Sun Apr 08 12:48:03 NZST 2018] Exception in thread "AWT-EventQueue-1" [Sun Apr 08 12:48:03 NZST 2018] java.lang.NullPointerException
[Sun Apr 08 12:48:03 NZST 2018]     at co.pylo.mcreator.a.<init>(SourceFile:676)
[Sun Apr 08 12:48:03 NZST 2018]     at co.pylo.mcreator.Launcher.lambda$main$0(SourceFile:128)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventQueue.access$500(EventQueue.java:97)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventQueue$3.run(EventQueue.java:709)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventQueue$3.run(EventQueue.java:703)
[Sun Apr 08 12:48:03 NZST 2018]     at java.security.AccessController.doPrivileged(Native Method)
[Sun Apr 08 12:48:03 NZST 2018]     at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
[Sun Apr 08 12:48:03 NZST 2018]     at org.GNOME.Accessibility.AtkWrapper$5.dispatchEvent(AtkWrapper.java:700)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
[Sun Apr 08 12:48:03 NZST 2018]     at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I believe the relevant issue here is, that the executing user does not have write rights to the installation directory. A perhaps somewhat related issue is, that MCreator uses paths relative to the current directory to find its libraries necessitating a change to the install directory.

Applications really should not rely on the current directory having any particular value relevant to them (other than it being used as the default place for Open File kind of dialogs.

Application paths should be relative to the path of the initial JAR file. User paths (i.e. settings files etc) should be relative to the users HOME directory.

 

Issue comments

Actually, it is normal for Java apps to be relative to the execution directory. There is no straightforward way to find the location of the jar. Run MCreator from the directory you installed it in and you should be fine.

In the future, all files related to the user will be stored in user home, and resources packed in the jar so this will not be a requirement in the future.

Regarding the read and write permissions, make sure that the user running MCreator has permissions to access these files. If you are using Unix system, you should be aware of this.

I disagree that it is normal for Java apps to be run from the directory where the jar or that it is hard to find the jar. After all it is given on the command-line.

It is not acceptable for all users on a machine to have write access to the installation of the program. That completely breaks the security of having separate users. Having separate installations for each user makes it completely unmaintainable.

Why exactly does the program need to write to the program files?