2

I'm working with Ligdx, an API for cross plattaform game development that by default generates at least 2 projects:

  • The core project: This is the one you are supposed to work on, where all the classes and logic should be placed.
  • The desktop project: This one is automatically generated from the core project.

The core doesn't have any class to start it because it's supposed to be started from the desktop (or other platforms) project.

It is also always selected -because its what you are working on- so pressing the "run" or "debug" buttons will attempt to run the core project and not the desktop one and immediately fail thus forcing you to select the desktop project before hitting run/debug. This can get extremely annoying, especially when debugging.

enter image description here

So is there a way to force Eclipse to always run the desktop project?

Nicolas Martel
  • 1,641
  • 3
  • 19
  • 34
  • How are you asking Eclipse to 'run' the core project? (Which part of the Eclipse UI?) – P.T. Oct 13 '13 at 17:10
  • Either the play button or the debug button in case I want to debug instead. I realize I can just click on the desktop project then run it but it's a little annoying to do everytime. – Nicolas Martel Oct 13 '13 at 18:06
  • @Nicolas Martel I've updated your question in order to clarify what you asked. If you don't like the edits let me know and I'll roll them back – 0x6C38 Oct 13 '13 at 18:16
  • Thanks, it's very clear. I took the liberty to fix your mistakes – Nicolas Martel Oct 13 '13 at 18:26
  • @Nicolas Martel Oh sorry about that, not a native speaker :S – 0x6C38 Oct 13 '13 at 18:28

3 Answers3

4

Rekaszeru's answer to this question shows how to set up Eclipse in order to always launch the previously launched application.

You simply have to go to preferences / run-debug / launching and check the "Always launch previously launched application" box as he shown in the picture he used to illustrate his answer:

enter image description here

This will not force one of the projects to always be launched but it would pretty much solve the problem unless you are working on multiple projects at the same time or you alternate between Web/Android/Desktop.

Community
  • 1
  • 1
0x6C38
  • 6,796
  • 4
  • 35
  • 47
1

If Your asking how to start a Core project from already existing project present in the eclipse then all you need to do is Right Click on desktop folder of the project and go over Run As and select Java Application


But if that is not what you have posted for I can only understand that you need to understand how a LibGDX project is deployed.... From Desktop project "In xyzMain.java" file you will have a method call to the core project saying:

new LwjglApplication(new Sample(), cfg);

This is where you'r Sample Class from the core project is called over.


But from the title I get a diff feeling that you wish to add another project to your already existing project... You can do that by changing the build Path of the project....by including Other proj to the one you wish to compile and run.

Hope this helped you out..

srikanth
  • 301
  • 3
  • 14
  • This is not what I asked. I only want Eclipse to start the desktop project rather than try to run the actual project with all of the code and logic. Libgdx is irrelevant here and is just background information. I want something like in Visual Studio where you can set an active project inside the solution and no matter which project you're editing, the run button will run the active project. – Nicolas Martel Oct 13 '13 at 18:08
  • Once if you run it ..the next time onward's you just need to click on the arrow beside the build button and select Main.java(the desktop class) file... – srikanth Oct 14 '13 at 08:31
1

I´m not aware of doing exactly what you have described, but I´d suggest using the Launch Configurations menus and dialgos to do what you want in a similar quick way.

Note that you can configure your launch configurations doing: Run -> Run Configurations... (also Run -> Debug configurations...)

Option 1).

Once you have run your Desktop Project, simply use the Run Drop-down button, which contain your launch configurations:

Drop-down button

Option 2).

Save a launch configuration file in your Core project (or wherever you want) using the last "common" tab of the launch configuration dialog:

Save the launch configuration in the project

Then you can simply right-click on your that file to launch your Desktop Project:

Launch your saved configuration file

P.S: I´d also suggest reading a little bit about run configurations in lars tutorial

ASBH
  • 541
  • 2
  • 6