I'm trying to follow the guide to export my project as a Java applet.
My project, as seen in Eclipse, has three directories:
Game
Game-Android
Game-Desktop
They were created using the UI Setup tool. The guide at http://www.thesecretpie.com/2011/05/being-like-minecraft-or-how-to-run-your.html is confusing and I don't understand these points:
Next step: add a new file called HelloWorldApplet.java (in the same
directory as other source files).
"The same directory as other source files". Well, I have three directories and they all have a source folder. In which of these three am I supposed to put this file? I tried placing it in Game, but Eclipse is unable to resolve com.badlogic.gdx.backends.lwjgl.LwjglApplet. If I put it in Game-Desktop it seems to be OK, but I'm not sure.
Create a directory called applet in your project dir.
Again, in which of my three directories?
Just export the whole project as jar in Eclipse
I can export a JAR for Game, Game-Android, or Game-Desktop. Which of these?
Related:
I happen to be using the JRuby JAR in my game to run some ruby scripting logic. Do I have to do something specific about it?
That blog is little old. For example, the JOGL backend is gone from recent version of Libgdx (so you don't need to worry about switching to the LWJGL backend). Also, the current LWJGL bundled into Libgdx is 2.9.0 (hopefully that doesn't change too much, though).
I believe the instructions are effectively packing up the "desktop" build of your app into an Applet (as the desktop is the only build that use the LWJGL backend), so assume Game-Desktop is the "same directory" that its talking about.
Thus, you should export the .JAR from your Desktop project.
On a related note, there is another way to run your game on the web, using the GWT backend. Check out the Setup & Running page (where its called "HTML5"). There are a bunch of caveats on using the GWT backend (not all Libgdx APIs work over there). (Hmm... I doubt this will work with the JRuby JAR, so probably not worth spending too much time on that.)
Related
I’m a novice programmer and I bit off more than I could chew. I’m using Netbeans 8.2 for the first time and I managed to hobble it together and install the Python 3.0 plugin followed by the Jython 2.7 plugin (never used either of these before.) I’m a model railroader and use a program call JMRI (but not its JAR file in my code) which is written in Java and my code is for trains so I chose Jython so I could share it with others.
I have a good working program! Now I want to create JAR files so I can share it. Clean & build does nothing, I click it and the output window remains blank. I right click the project and see Clean and make egg. Researching the internet I find that I’m not the only one that has struggled with making Jython JAR files. But the Q& A are dated (2011-2014) and refer to programs JUMP and JthonC which appear to be unavailable now.
I’m looking for tutorials and examples and of course experienced users to guide me. What program (or plugin) do I need to make the JAR file?
I'm using NetBeans 8.0 and my problem is when I make (clean and build) to my java project....the jar will be build in the current path of the project and works good with no problems, But, when I make a copy of the jar to my desktop, the application jar doesn't run. why?
Except for the most trivial programs you cannot just copy a jar file containing your classes to a target machine and expect it to run, as Sun never got around to do a well-defined single-file deployment method for a desktop application (similar to what WAR files do for web applications).
You must essentially copy your code, and the library jars you depend on, and a launcher script telling the JVM which jars you have, and an icon if you want that and usually more too. The lack of a standard method means that there are many ways to do it and you need to choose the one best suitable for you.
A solution for your problem here and now is to look at https://netbeans.org/kb/articles/javase-deploy.html which discusses how to deploy Java SE applications using netbeans by creating a runnable jar with an embedded classpath. I am not very familiar with Netbeans but the steps look very sensible and will teach you the details on the process.
When you get more experienced you will want to be able to automate the process more. The first step in that direction is to learn Maven - a bit tedious in the start but it pays of in the long run.
I am trying to make the HelloWorldImage example from Beginning Java Development with Libgdx but I can't get the project to read the image.
This is what the project directory and first class looks like:
And this is the error I get when I try to run the program:
I also used "Beginning Java Game Development with LibGDX" to learn LibGDX, so I know you are using BlueJ because that's what the book does. You definitely can build LibGDX games with BlueJ: the author uses it to develop dozens of games in the book. That said, the other commenters are correct: BlueJ is an "educational IDE" arguably suitable for learning Java. You could consider using a different IDE, especially if you already know Java.
The book's source code is available for download on GitHub. Download and extract the "978-1-4842-1501-2_Ch01_code.zip" archive and see how the project files are supposed to be arranged. If you compare your project to the source, it looks like you're missing the "+libs" folder which should contain gdx.jar, gdx-backend-lwjgl.jar, gdx-backend-lwjgl-natives.jar, and gdx-natives.jar. I know the author described several ways these dependencies could be installed, so perhaps you have used an alternative method, but I recommend you use the structure you find on GitHub to ensure it's working.
(If you want to use a different IDE like Netbeans or Eclipse but don't want to use LibGDX's Gradle build tool, I wrote a short Maven pom file that can be used to build the LibGDX games in the book.)
You don't have libGDX's dependencies (i.e. libGDX libraries etc.) included in your program's classpath.
I don't think BlueJ even has an option to use dependencies. Use Eclipse, NetBeans or IntelliJ, the only 3 officially supported IDEs for libGDX (and the most commonly used).
Edit: You can add your libraries in a folder called +libs in the BlueJ project directory.
I would not recommend using BlueJ - BlueJ is, IMO, often used for teaching Java concepts (because of its object visualizer etc.) but has an extremely limited feature set.
Also, BlueJ Gradle integration doesn't exist (a useful tool for development in general.)
Instructions for setting up libGDX with these 3 IDEs are available here.
I'm trying to use a JNA library in my project.
My situation is as follows:
I have an applet that shows camera input.
If I run the Applet using the command run as applet I get the correct result:
an applet that shows the camera input
If I remove jna.jar from the build path it gives me error as expected.
If I rename the directory of the native plugins it gives me error as expected.
If I try to run the whole application I get the error:
GStreamer-WARNING **: Failed to load plugin C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstwavparse.dll on 30+ dlls
The path C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\ is the one that if renamed makes the applet crash (so the correct one) and jna.jar and the library that used by JNA are imported in each project involved: the root project from which the application is started and the view project that instantiates the camera showing applet.
As previously suggested, I have tried
System.setProperty("jna.library.path","C:/Users/aaa/Desktop/bbb/ccc/video/library/windows64/plugins/" );
etc... in all possible forms to reference the correct directory but to no avail.
The library is a 3rd party library and actually should work.
The problems may be in my total lack of knowledge of JNA and/or Gstreamer or even of some basics at this point.
Is there any workaround? Why do the applet and application that instantiates the applet work differently when referencing DLLs... or Gstreamer DLLs... or the Processing 2.2.1 included Gstreamer DLLs?
Ok i managed to make it work this way: if i write a main directly in the View project and add the applet to a panel it now works... so that solves some issues(the applet was in a panel even before anyways)... the same exact dummy main gives the warning as before if run under root project alas: failed to load plugin:"correct path"
As said before i have a root project and a view project(N Vproject to be frank) the video lib is included in the VProject and the dlls are under is project resources. Is it possible that running the app from the main project something (like different system variables) end up causing problems?
Just not knowing the issue i precedently added and removed(and combinations) all that could be added in relation to jna platform and to tha jna-using-video lib to both projects.
i really do care about uncoupling in this case because im sort of writing a framework and this is a major limitation. Any insight?
I'm trying to use the JNotify library along with netbeans, however I don't know the proper way to configure it. Everything I try, the lines involving jnotify (eg. import net.contentobjects.jnotify.*) are underlined in red. Google seems to show nothing helpful regarding netbeans with jnotify, although I assume it's something simple like adding it to the classpath. I've tried adding the .jar as a library for compile & for run, no go.
The line i've been provided for running my app from the jnotify page:
-cp jnotify.jar -Djava.library.path=.
should I be using this as my compiling options or VM run options or both? seeing as I don't want to have to distribute my app with a .dll or .so file or the jnotify .jar.
Everyone on this site recommends using such and such a library, but they don't realize how hard they can be to set up (jnotify,boost,curl), and most who recommend them have probably never even used them themselves.
You're right, you have to add every library you use in your programs, into the projects classpath:
Click on the project node in your 'Projects' window. It should by default have a node called 'Libraries'.
Right click this node and select 'Add JAR/Folder'
Locate the JNotify.jar on the file dialog and press 'Open'.
Refresh your project, or just give netbeans some time to rescan the classpath, and you should be good to go.
There definately is something wrong with your classpath. While the above is exactly how you set the classpath when running a Java program, its different for a NetBeans project.
Follow these articles on how to add extenal jars to a NetBeans project.