Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (807)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  solved LibGDX package set up  (Read 664 times)
0 Members and 1 Guest are viewing this topic.
Offline FabulousFell

Junior Devvie


Medals: 6



« Posted 2020-05-05 21:47:30 »

When I create a LibGDX project, you create that first package in the core directory, usually starting with com.xxxx.  Do all subsequent packages need to go in that package?  I'm asking because I'm getting an error when I do a build with gradle (cannot find main class DesktopLauncher), but I wanted to know this answer before I changed everything around.  Thanks.
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #1 - Posted 2020-05-05 21:59:05 »

if it helps, here's my build.gradle file:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
apply plugin: "java"

sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../android/assets"]

project.ext.mainClassName = "com.mygame.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets")

task run(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
}

task debug(dependsOn: classes, type: JavaExec) {
    main = project.mainClassName
    classpath = sourceSets.main.runtimeClasspath
    standardInput = System.in
    workingDir = project.assetsDir
    ignoreExitValue = true
    debug = true
}

task dist(type: Jar) {
    manifest {
        attributes 'Main-Class': project.mainClassName
    }
    dependsOn configurations.runtimeClasspath
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
    with jar
}


dist.dependsOn classes

eclipse.project.name = appName + "-desktop"


And my java version is:
1  
2  
3  
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode, sharing)
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #2 - Posted 2020-05-08 18:21:23 »

Well, does anyone see anything wrong with that Gradle file?  I'm absolutely stumped on why the Gradle build passes fine but wont launch because of that error.  To my knowledge Gradle is using the same version of java, and in the build path, the main class is indeed DesktopLauncher.  Anyone have any ideas on why this is happening?

Edit: I'm a noob with Gradle and it might be something easy and dumb, but if it is I can't figure it out.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Kernel


Medals: 196



« Reply #3 - Posted 2020-05-12 13:52:47 »

whats the "package" statement in your DesktopLauncher.java file?

Mathias - I Know What [you] Did Last Summer!
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #4 - Posted 2020-05-12 23:33:27 »

whats the "package" statement in your DesktopLauncher.java file?

Here's the file:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
package com.mygdx.mygame.desktop;

import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.mygdx.mygame.MyGame;

import helpers.GameAttributeHelper;

/**
 * Launch game on desktop.
 *
 * @author Fabulous Fellini
 *
 */

public class DesktopLauncher {
   public static void main (String[] arg) {
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      config.addIcon("artwork/logos/GoldenAgeIcon.png", FileType.Internal);
      config.title         = "The Golden Age: Legend of the Seven Swords";
      config.foregroundFPS = GameAttributeHelper.FRAMES_PER_SECOND;

      // Full screen.
      float f       = 1.0f;
      // Phone screen.
      //float f       = 0.5f;

      float width   = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
      float height  = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
      config.width  = (int)(width * f);
      config.height = (int)(height * f);
      new LwjglApplication(new MyGame(), config);
   }
}
Offline cylab

JGO Kernel


Medals: 196



« Reply #5 - Posted 2020-05-13 06:10:51 »

Then you mainclass property in the gradle file needs to be
com.mygdx.mygame.desktop.DesktopLauncher.

at least in your first post it misses "mygdx"

Mathias - I Know What [you] Did Last Summer!
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #6 - Posted 2020-05-13 14:21:34 »

Then you mainclass property in the gradle file needs to be
com.mygdx.mygame.desktop.DesktopLauncher.

at least in your first post it misses "mygdx"

Yes!  I think that has to be it.  I will try when I get a break from work.  Thank you!
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #7 - Posted 2020-05-13 19:21:49 »

Ok that worked!  Now, it can't find the images lol.  I read that the assets folder has to be a source folder ("used as source" in Eclipse) or else it wont compile, so I changed it to be a source file, but that still didn't work, getting the same error.  It's pointing to the core/assets folder, so I'm not sure what's wrong.  I'm going to do more investigation into that tonight.
Offline FabulousFell

Junior Devvie


Medals: 6



« Reply #8 - Posted 2020-05-13 20:42:02 »

Dammit how do you put the "solved" tag on a post?

Edit: I guess it just needed a second.  Solved tag solved.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (843 views)
2019-09-04 15:33:17

hadezbladez (5778 views)
2018-11-16 13:46:03

hadezbladez (2597 views)
2018-11-16 13:41:33

hadezbladez (6195 views)
2018-11-16 13:35:35

hadezbladez (1494 views)
2018-11-16 13:32:03

EgonOlsen (4729 views)
2018-06-10 19:43:48

EgonOlsen (5779 views)
2018-06-10 19:43:44

EgonOlsen (3270 views)
2018-06-10 19:43:20

DesertCoockie (4171 views)
2018-05-13 18:23:11

nelsongames (5481 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!