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?
Related
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 an enthusiast attempting to play around and add things to an app that I have been using for the past year which the source codes are available in GitHub. Problem is when I clone or download the repository and open it in Eclipse, I get a ton of error codes whenever I try to 'run as' Java app (in particular I am unable to find the 'main class/starting point' there's way too many files to chose from to find it and most don't work) and when I try to extract the files to an executable jar it gives me a JAR exe that is unusable :-(. I know that the files are workable since I do use the executable jar that is available from the developer and others have also toyed around with the source codes.
Can anyone assist me with this? Maybe I am using the wrong Java manipulator/application. The program I am using for opening these files is Eclipse IDE for Java Developers and my operating system is 64bit Windows 10.
Also, here is the GitHub URL for the repository, in case anyone asks: https://github.com/DraqueT/PolyGlot.
I thank anyone who can be of some assistance as I have been working on this forever and can't seem to find a solution.
The github project looks a lot like a utility library than a full application. But the following could help:
Try to study the README file attached to the github project. (There is one in the source code according to the author). This would help you to setup the project.
Make sure to download all the dependencies for that project. Again, the author has provided some of them in the github project (I could see some Apache POI libraries in there somewhere), but getting the required jars on the maven repository isn't that difficult.
It would also help to know what type of project it is. For example, having a main method in a web application doesn't do much for you, but a Java SE project would need a main method to run. So try to find out what kind of project it is.
If all else fails, you could try to contact the owner of the repository or one of its contributors to assist you.
Cheers!
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 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.)
Im working on building a java application in windows vista using the Emotiv Epoc Neuroheadset, http://emotiv.com/index.php.
I'm new to java and having a really tough time getting started. I have some examples that came with the headset I'm trying to run in either eclipse or netbeans (at this point I really don't have a preference, suggestions?)
The user manual gives these directions:
*2. Package content: Jna.rar, Edk.java, EmoState.java, EDkErrorCode.java
Example 1: EEGLog
Example 2: EmoStateLog
Developer‘s guide: Step 1: Add the JNA library to your project. Step 2: Add Edk.java, EmoState.java, EdkErrorCode.java to your project. The classes in these files contain methods calling the APIs from Edk.dll using JNA library. You can find more information about the conversion between data types on the JNA's homepage.*
This is all Chinese to me! Can someone explain to me exactly how to do these steps (in a way a small child who have never used eclipse or netbeans before can understand!) Somebody from the Emotiv Epoc forum gave me these directions as well:
*To see how to Java wrapper examples work you should install Eclipse and open, compile them. You put edk_utils.dll and edk.dll into System32 or the same root directory of each example as EmoStateLog, CognitivExample,... before running them.*
My problem is I dont know enough about the IDEs to run these examples. Am I supposed to make a new project then add these files? Or do I open one of the examples, then add the .dll files and the JNA library? How do you add libraries to a project? Where do I put the .dll files?
Thanks in advance!
I know this is fairly simple stuff but its always the simple stuff thats hardest to figure out it seems!
-Eric
Based purely off of what you're saying here...
Developer‘s guide: Step 1: Add the JNA library to your project. Step 2: Add Edk.java, EmoState.java, EdkErrorCode.java to your project. The classes in these files contain methods calling the APIs from Edk.dll using JNA library. You can find more information about the conversion between data types on the JNA's homepage.*
Create a new project in Eclipse.
Add Edk.java, Emostate.java, EdkErrorCode.java into the src folder
Add the JNA library into the libs folder. (Make sure the library is in the project path, otherwise Eclipse won't detect it.)
Whether or not it will compile depends on if those are the only supporting files.