Jump to content

Need help with IntelliJ 2020 Run Configuration


mcnuggies

Recommended Posts

forge_client gradle task always fails with error "Could not find or load main class net.minecraftforge.userdev.LaunchTesting"

 

To give some context, I have gotten the forge_client task to work in the past; I'm positive this is an environment issue, but not sure how to fix it. This issue started once I updated to IntelliJ 2020. Additionally, I am not a Java developer in my day job. While I have decent experience with Java, I am normally a Node.js developer (JS, yuck). This is all to say that I "generally" know what I am doing, but need some environment setup help since I don't usually use IntelliJ. I've seen many other people with this exact issue, so I think this post may help many others in the future.

 

Here is a stack trace of the latest run:

 

Additionally, I've attached a screenshot of the Run Configuration for the forge_client task. Keep in mind that this screenshot is from IntelliJ 2020.3; if you have a different version, it will probably look different (much to our collective dismay 😐)

 

My Setup:

  • System details
    • Ubuntu 18.04.5 LTS
    • Java - OpenJDK 1.8.0_282
  • IDE Details
    • IntelliJ IDEA CE 2020.3
    • Gradle Version 4.9
  • Forge Details
    • Cloned repo from GitHub
    • Branch 1.16.x
      • I have tried other branches and hit a similar error in the same spot ("Could not find or load main class..."), but the class name is different

 

What I have tried:

  1. Forge Docs - "Getting Started with Forge" (general modding with Forge docs)
  2. Forge Docs - Contributing to Forge - "Getting Started" (docs on how to contribute to the actual Forge code base)

 

In both of these documents, the "core step" appears to be to run the forge_client task, which should start the forge client from within the repo. In both cases, I've tried:

  1. Opened the build.gradle file as a project when opening it in IntelliJ > wait for project setup stuff to finish
  2. Run the setup gradle task > Run genIntellijRuns gradle task > Run the forge_client gradle task 
    • This is where I hit the "Could not find class" error

 

Notes

  • The clean_client gradle task works without issue, presumably because it doesn't need this LaunchTesting class
  • If I change the dropdown in the run configuration from -cp Forge.forge to -cp Forge, I get a run configuration error saying the LaunchTesting class doesn't exist in Forge module

 

Any help on this is much appreciated! I've found several posts with this exact problem, but no follow up - makes me think it was some simple config issue they figured out and never posted the solution (shame). Us simpletons would like to know how to make minecraft mods as well 💘

 

 

 

IntelliJ_2020.3_RunConfiguration.png

Edited by mcnuggies
Link to comment
Share on other sites

Usually when I get error like this I attempt the build gradle again, and then the "genIntelliJruns". if not I usually go and make a new project and move my files over after the fact.

Might I also recommend this plugin: https://plugins.jetbrains.com/plugin/8327-minecraft-development

It helps to get you started if you're having a rough time getting set up

 

xo

 

  • Thanks 1
Link to comment
Share on other sites

Awesome, thanks @MistaOmega - I will give this a shot and see if it helps. Will report back with my findings 🤘

 

Update!

  • That plugin worked for me!
  • I was unable to figure out how to fix my old environment, but creating a new one with that plugin got me up and running without issue!
  • I'm not sure what this plugin does differently from the setup docs, but for anyone else hitting this, try the plugin first
    • I intend to come back later and document what needs to be done when you do this manually

 

Just a heads up for others! The project that this plugin sets up is quite a bit different from the cloned Forge repo. This isn't necessarily a problem, but means that you'll likely have trouble if you try to follow Forge's "Getting Started" docs while using this plugin. If you use the plugin, that should be considered your entire "getting started" process. Once you complete setup, simply start modding and testing your mod with the runClient gradle task.

Edited by mcnuggies
Indicating to others that there is a difference between the plugin-generated project and the project that Forge docs assume you have (specifically, around the "Getting Started" docs)
  • Like 1
Link to comment
Share on other sites

While I am unblocked on actually creating mods, there are some things I would like to do within the actual Forge codebase. I'll keep trying to fix the class not found error and will update if I find a solution for that. With that said, I am going to spend some time playing with actual modding and then will try to get the client running from within the Forge repo again.

 

Mentioning this so others know that I am still technically hitting this issue, but using the plugin allows me to create and test mods without needing to address this problem.

Edited by mcnuggies
Link to comment
Share on other sites

Solved! But there is more to the solution - see the last comment to this post. Basically, if you make the changes in this comment, but still run the Gradle forge_client ("Run Configuration") instead of the "Application", you will still hit this error (the classpath can't be set for Run Configurations in IntelliJ 2020.3).

 

The issue was two-fold:

  1. My Run Configuration was incorrect
  2. My project's Gradle settings were incorrect

Post-mortem:

  • The Run Configuration could not be corrected without first correcting the Gradle settings
    • The option you need to select simply won't show if the project's Gradle settings are incorrect (kind of a "duh" moment, but as I mentioned, I am relatively inexperienced with IntelliJ 🙃
  • You have to fix Gradle before you can fix your run configuration
  • I'm not entirely sure of how "obvious" this may seem to most, but I had no clue:
    • Use gradle from 'gradle-wrapper.properties' file
    • Set the Gradle JVM to the "Project SDK" (NOT OpenJDK - not sure why, yet)
  • Once you fix the Gradle settings, rebuild the Gradle project then run edit the Run Configuration for the forge_client task
    • After fixing your Gradle, you should be able to click the dropdown and change it from -cp Forge.forge to -cp Forge.forge.userdev (you should see the option available to you - if not, something else is going on and I don't know how to help you... sorry 💔)
    • Save the change to your Run Configuration > run the genIntellijRuns task > run the forge_client task > you should be good to go now!

Screenshots:

Intellij_2020.3_GradleSettings_Correct.png

Intellij_2020.3_RunConfiguration_Correct.png

Edited by mcnuggies
Finally figured out last bit of issue - clarified comment
  • Like 1
Link to comment
Share on other sites

So, weird update - I know I got the forge client actually running, but only once (strange, I know). I know it was the Forge client (and not the one from the plugin project I created earlier), because there was a "Mods" button on the main page and had two mods listed:

  1. Minecraft
  2. Forge

This is what I am trying to get to; a "vanilla" Forge client running from the repo source code using the gradle tasks. However, it seems weird to me that it only worked once. It leads me to think that maybe I am on the right track, but have some other issues to address. Will update when I know more!

Link to comment
Share on other sites

Solved!!! (For real, this time)

 

So, the "solution" I listed before actually is the solution. The last thing I goofed up was that I was running the forge_client Run Configuration and not the Application (which is what I used to set the class path for the userdev module). 

 

Refer to my screenshots, but in general: Elephant is bad, Application Icon is good (in the dropdown)

 

YES:

YES.png

  • This is the what uses the configuration that I fixed in my previous "solution" comment

 

NO:

NO.png

  • The problem with this option is that, in IntelliJ 2020.3, you cannot specify the classpath - you need to use the forge client Application (but this does require that your gradle configuration is correct, so see my comment above for that)
Edited by mcnuggies
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.