nusCS2113-AY1819S1 / forum

5 stars 0 forks source link

Could not find or load main class seedu.address.MainApp #91

Open Psyf opened 6 years ago

Psyf commented 6 years ago

Hi @okkhoy

Context: I was cleaning up my local repo (getting rid of branches except master). Afterwards, when I opened IntelliJ, the folder structure was gone. I thus closed the project, and reimported as per the steps in AB4 DG.

Problem: Even after gradlew precessResources returns success, running MainApp.java yields the following error:

Error: Could not find or load main class seedu.address.MainApp
Caused by: java.lang.ClassNotFoundException: seedu.address.MainApp

Process finished with exit code 1

What I tried:

FAILURE: Build failed with an exception.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. See https://docs.gradle.org/4.8.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s 1 actionable task: 1 executed



Looks like junit can't be found for some reason. I looked at my import statements and @Test statements, and they were not in red.

Please advise. 
okkhoy commented 6 years ago

Err... shot in the dark: Is your project structure OK? Sources root marked appropriately? This should get your MainApp running.

For junit, you need to provide a version (not sure if you have done it but still it is not picked up)

Psyf commented 6 years ago

Later after import, the project directory was properly back in display. Project structure has JDK 9 correctly selected. Is there something else I should check?

Psyf commented 6 years ago

For the junit version, I'm guessing mentioned inside grade.build file. Here's where I find it: (sorry for literal screenshot, my laptop is off the grid rn) img_20181103_185635

Psyf commented 6 years ago

If I can't solve it soon, I guess I'll just do a clean reinstall.... Again.

okkhoy commented 6 years ago

Junit seems fine. No issues.

Project structure has JDK 9 correctly selected. Is there something else I should check?

I meant, the sources folder in the directory structure: image If they are identified properly, the ide should find the MainApp#main()

If not, I am not too sure. I have asked the AB devs, let me see what answer they have.

Psyf commented 6 years ago

idea64_2018-11-03_19-50-44

src/ seems okay to me. Might this Application in red be the problem? It was red since 1.1 anyway, so I don't think so.

EDIT: I followed IDEA's suggestion and chose the first option. Application is no longer red but MainApp#main() is still not found. I verified main() was actually there as the last function of the file:

public static void main(String[] args) { launch(args); }
okkhoy commented 6 years ago

I first thought "Seems like your JavaFx is not detected?" Since you say it was red since 1.1, I don't know cause 😞 Let us wait for the AB dev's to say something?

Psyf commented 6 years ago

Update: Reinstallation did not help. More info for your AB devs: idea64_2018-11-03_20-15-03

Yeah, let's wait. I was looking forward to binge coding this mini-vacation :(

0WN463 commented 6 years ago

This comment may be incorrect / not apply to you, but when I see the

Could not find org.junit.jupiter:junit-jupiter-api:.

It should not be the jupiter version of junit right? Cause for my project, we didn't use the jupiter version but the "normal" version. EDIT: Then again, my group is using AB3 so it might not apply

Psyf commented 6 years ago

@0WN463 I'm not sure either.

Interesting observation: In build.gradle I changed one line in dependencies{} from implementation 'org.junit.jupiter:junit-jupiter-api' to implementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'

After this, gradlew and gradlew build run properly. Still no luck with MainApp#main() though :/

okkhoy commented 6 years ago

From the devs:

First step is to always:

  1. Do a CLEAN clone of the repo
  2. Re-set up the project.
Psyf commented 6 years ago

Hi @okkhoy ,

I'm not sure what a CLEAN clone of the repo is. Do you mean delete my clone and clone from origin/master (personal fork)? If so, I've done that.

I've re-setup the project multiple times too.

Good news is: I can now run it through gradlew run on IDEA's terminal. The green play button on the top right still can't find the MainApp#main()

okkhoy commented 6 years ago

Good news is: I can now run it through gradlew run on IDEA's terminal.

Great! Some progress πŸ‘ though that is not the full solution.

The green play button on the top right still can't find the MainApp#main()

Is the run configuration ok?

Is your origin/master consistent with your team's upstream? Clean clone means remove everything related to your codebase from your local and clone. Could also try to delete the .gradle folder in your home folder (not sure if that helps though! but it will redowload all the dependencies again)

Psyf commented 6 years ago

Yes, sir. The origin/master is up-to-date.

I'm not sure what the configurations should look like. I'll match with a friend's I think. Here is a screenshot: idea64_2018-11-04_01-29-26

I've done gradlew clean and that's not helped.

To be honest, I don't know much about gradle or maven or java specific development tools that well even as the mod comes to a close.

okkhoy commented 6 years ago

Your run configuration seems OK. I have run out of ideas now πŸ˜•

We don't expect you to master build tools in this module. You need to know the basic usage and understand something when you read a build.gradle file!

This seems like some corner case that even many experienced folks may need time to figure out. For all you know, you may be hitting some IntelliJ bug, which may be unrelated to gradle.

Psyf commented 6 years ago

Well, that sucks. I can't use the debugger anymore and have to rely on white-text logs from the terminal. I guess I'll just live with it till v1.4. Don't want to risk IDEA breaking down again before final release.

Thanks for the help everyone. Feel free to close the issue if you want @okkhoy

okkhoy commented 6 years ago

If it helps, try it on a VM where you start with a clean slate.