简体   繁体   English

Netbeans Maven项目在Windows中运行,但不在Linux中运行

[英]Netbeans Maven project runs in windows, but not in Linux

I have a problem with our school group that the Maven project opens fine in windows, but when importing the project via GitHub (exactly the same files) the program gives a nullPointerException with an image. 我的学校团体有一个问题,Maven项目可以在Windows中很好地打开,但是当通过GitHub(完全相同的文件)导入该项目时,该程序会给出带有图像的nullPointerException。 The Image is available in the project. 该图像在项目中可用。 The program finds the image as well, because if you look in the GUI builder, the images are visible. 该程序也会找到该图像,因为如果您在GUI生成器中查找,则这些图像是可见的。 The following is seen even though the Build is succesfull, but no GUI is shown: 即使Build成功,也会看到以下内容,但未显示GUI:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at orfpred.GUI.initComponents(GUI.java:62)
at orfpred.GUI.<init>(GUI.java:21)
at orfpred.GUI$8.run(GUI.java:295)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

and the line of code 和代码行

setIconImage(new javax.swing.ImageIcon(getClass().getResource("/orfpred.png")).getImage());

at first I thought it was a backslash problem (windows and linux switches those) but thats not the problem either. 起初,我认为这是一个反斜杠问题(Windows和Linux会切换这些问题),但这也不是问题。 I tried using google to find a similar problem, but no luck so far. 我尝试使用Google查找类似的问题,但到目前为止还没有运气。

Sorry if I haven't provided the right information, I am quite new with Java. 抱歉,如果我没有提供正确的信息,那么我对Java还是陌生的。 One of the school assignments is that the GUI we have to build works in windows and linux, so thats why it is an important issue. 学校的一项任务是,我们必须构建的GUI在Windows和Linux上都可以运行,因此这就是一个重要的问题。 additionally we are unable to work independently via GitHub if it doesn't work on my laptop. 此外,如果无法在我的笔记本电脑上运行,我们将无法通过GitHub独立工作。

Many thanks :) 非常感谢 :)

The problem was that the filenames in Linux are case sensitive, and not in windows. 问题在于Linux中的文件名区分大小写,而Windows中不区分大小写。 So by making the GUI using the GUI-maker in windows, the code will contain filenames with only lowercase letters. 因此,通过在Windows中使用GUI-maker制作GUI,代码将包含仅包含小写字母的文件名。 So either change the code or make sure all filenames are with small letters only. 因此,要么更改代码,要么确保所有文件名都仅包含小写字母。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM