How to create libGdx based library - java

I want to create my own library which will use libgdx framework. As a result I want to get jar of my library which can be added to any other project which also uses libgdx.
The problem is that I can't find any tutorial how to do it. I can create normal libgdx project, but how I can get jar library from it? Maybe I need to create gradle based project and compile libgdx dependencies?
If somebody has experience in creating libgdx based libraries or extensions, please share your experience.

Question is a little old but for others that may stumble here; This is the best solution I've found for creating/using your own library project in another LibGDX project. Though I believe the HTML project requires further steps that I haven't investigated.

Using eclipse:
File->Export->Java->JAR File->Export Generated Class Files and Resources
AFAIK You can tell it not to package required libraries with the JAR.

Related

NoClassDefFoundError, trouble loading library I created before I use it in my main jar

I understand what this error is 'java.lang.NoClassDefFoundError', and why it is caused. My issue is that I don't know how to solve it.
I am attempting to use an external utility library I made for creating inventories in a plugin of mine, and I compiled that library jar in with the plugin I was creating, and upon start up it gave me that error. Any ideas on how to solve this?
I figured that if I compiled the library with my .jar, it should load first to solve this issue...?
If you are using an external library you will need to shade the dependency into your plugin. Or if it is another plugin, ensure your plugin depends and loads after.
https://maven.apache.org/plugins/maven-shade-plugin/
https://bukkit.gamepedia.com/Plugin_YAML
I also highly recommend you ask for help on SpigotMC.org or Bukkit.org. There are thousands of Bukkit-Specific plugin developers on there willing to help.

Testing updated jar in project [duplicate]

We have a lot of jars which have been added over a period of years to the project and their usage has not been documented anywhere. I want to figure out references of any class in the jar in java or jsp files.
Now for our new jars we don't have this issue as we use Maven and it helps us maintain dependency etc much better. But I am trying to determine some of the old jars
Is there any way in Eclipse, or any other tool, to do this?
One way which I can think of:
You can use Relief to get a view of your whole java project. I haven't used it though, but have heard good things about it.
Update:
Finding unused jars used in an eclipse project

correct or optimal way to configure eclipse project dependecies

Hi: I realize my question is probably going to sound vague and probably not specific, but I am grasping for a general direction to go.
I was tasked with coding a POC that in general would make some REST calls from a Java client and compare the results. Not wanting to re-invent the wheel I asked if there was some existing code that already had some http posting functions I could make use of. I was directed to a particular java file that was a part of a much larger project and in system of interrelated projects.
My project is a java application project in eclipse and I imported the java file mentioned above with it's project as a peer gradle project into my workspace. This introduced a whole lot of errors that are caused by missing dependencies. The file, it's project and it's related projects all compile when they're all imported into another workspace as gradle projects.
Was importing the file and it's project as a gradle project at the same level as my POC/testing code not the correct way to make use of existing code? The missing dependent jars can all be found deep within cache directories referenced in the External jar/Libraries section of project properties but I don't think harvesting them and getting them to a place that my class path would include is the correct fix.
Isn't there a correct or optimal way to have arranged these items to have avoided this state?
Thanks for any/all assistance you may provide.

Gdx.files.internal won't work (blueJ)

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.

Android Unable to access java files in library

After a lot of struggle and research I am writing this for help. Being a new in to Android and Java literally spent few days. I am sure I am missing something silly but need insight.
I am using Android studio and have added Zxing QR scanner in to my project. Now I want to edit few methods in the library to do some customisation. I have added the library via Gradle. This is the library I have used https://github.com/dm77/barcodescanner.
I have followed the basic instructions and added the library via gradle. Integration is successful. Now I want to customise the UI. So I got hold of the library here
When I got hold of ViewFindView and tried to edit the method, I wan not able to edit it. Then I realised it is a class and also auto generated. I am supposed to edit the Java files.
The respective java file with all the code in the methods is here
ViewFinderView.java
How do I use it?
Is there a way to get hold of the java files respect to those class files.
How can I edit those files so that I can customise them?
I think all the above questions are kind of same. What do I do?
I am happy to provide more information.
Greatly appreciate your time. Thanks in advance.
I have added the library via Gradle.
That is your problem. In order to add the library to your project you have to import it as a module instead.
Download the repository (either via git clone or download as zip from Github)
Import project as a module in Android Studio (File -> Import Module or File -> New -> Import Module)
Edit source files
You will need to make your changes to the files in the imported module not the ones found in the build directory.

Categories

Resources