Running app in IDE stops working

只谈情不闲聊 提交于 2020-01-13 20:02:08

问题


Last week I finished development on a test app and ran it successfully in all simulators. Today I decided to look at publishing the app and used "Sent Android Build". Build status "Successful". Then tried running jar from command line and got:

peter@PeteSuse:~> java -jar "/home/peter/NetBeansProjects/mobile-apps/pGame/dist/pGame.jar"
java.lang.ArrayIndexOutOfBoundsException: 0
    at com.codename1.impl.javase.Executor$1.run(Executor.java:84)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)

So tried to run from GUI and got:

run:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
    at com.codename1.impl.ImplementationFactory.createImplementation(ImplementationFactory.java:69)
    at com.codename1.ui.Display.init(Display.java:566)
    at com.codename1.impl.javase.Executor$1.run(Executor.java:112)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)

Java version:

peter@PeteSuse:~> java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (IcedTea 3.3.0) (suse-23.1-x86_64)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

I am using Netbeans (new to this) on Suse Linux 42.1 64b.

Have I lost a library somewhere? or something else?


回答1:


Thanks guys. I fixed the problem by adding jfxrt.jar to the Libraries in NetBeans.




回答2:


JFXPanel is in the JavaFX library.

See: JavaFX and OpenJDK for info on why JavaFX is not available by default in your OpenJDK distribution.

  1. If your linux distribution makes an open JavaFX package available (like ubuntu does: Why is JavaFX is not included in OpenJDK 8 on Ubuntu Wily (15.10)?), then you can use that.
  2. Otherwise you can build from source (for the adventurous yak shaver).
  3. Or, easiest, is just to an Oracle Java distribution.

I don't know codenameone or have any idea how it works. Possibly whatever it is, you could ask the creators to package their thing as a self-contained application, so that it ships with a compatible Java runtime, which would (potentially) avoid issues such as you are encountering. Not knowing codenameone, I don't know if that would make sense or not.

I also don't know the cause of your original ArrayIndexOutOfBoundsException as that looks internal to codenameone or your use of it.


With regards to NetBeans, you might need to set the Java platform to one with JavaFX installed (in case you have multiple Java platforms installed on your machine).




回答3:


You can run a Codename One application in the simulator by pressing the play button in the IDE. It won't work for you from Command Line and shouldn't since the app shouldn't have a main() method.

You can execute the Codename One simulator from Command Line using:

java -jar JavaSE.jar:dist/MyApp.jar 

Notice this assumes your project is the working directory.



来源:https://stackoverflow.com/questions/43196710/running-app-in-ide-stops-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!