-3

I created a game using LibGDX and I'm trying to figure out how to run a jar without having the images and such within the same folder as it. How do I make it so the jar itself is self sufficient and has the assets contained within it?

Pendi
  • 15
  • 4

1 Answers1

0

If you want to export standalone jar(containing all assets of your game) from desktop module.

Libgdx uses gradle for project building so Hopefully you're using gradle and IntellijIDEA or Android Studio as IDE.

  1. Use Terminal

    • View -> Tool Windows-> Terminal or Alt+ F12

    • run command

      on window gradlew desktop:dist

      on Mac ./gradlew desktop:dist

    • It will put all your asset from your assets folder of android module into your jar. Your can find your jar in desktop module.

  2. Create jar with Artifact

    File -> Project Structure -> Artifacts -> Add(+) -> Jar -> From module and dependencies ->

    Module : desktop Main Class : DesktopLauncher

    then OK

    In OutputLayout tab -> Add Copy of(+) -> Directory Content -> Choose your Android Assets folder -> Apply -> Ok

    Then Build -> BuildArtifacts. -> desktop.jar -> build

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65