Cannot find or load main class 关注
I am trying to run a Java program like:
$ java -jar Neo4jImport.jar
But I get
Error: Could not find or load main class MongoDBImport.App
Where do I look to remove or rename this? I have looked all through the project and could not find MongoDBImport.App. Main should only exists as Neo4jImport.App.
Assuming you are building the JAR with IntelliJ IDEA via an artifact configuration, go to File > Project Structure > [Project Settings] > Artifacts. Find and select the artifact definition. Toward the bottom middle will be where the manifest file and the main class are defined.
I have same problem but this solution is not working for me :(
@Ramya Can you provide more details on the problem you are having? Are you running a command via the command line or an action in IDEA? What's the error you are getting? Can you paste the content oh the JAR's manifest.mf file? We can then try and determine what the issue might be.
I have the same issues:
The manifest is into /resources directory:
Ps: Inside the .jar, the content of the MANIFEST.MF is the same.
I avoid the issues, the problem was the dependency
I don't know why, but if I insert that dependency the jar don't works.
I am having the same problem. All applications that I create (I have 5 commercial applications created by IntelliJ using JavaFX) are unavailable to run in terminal and native bundles does not work too. I am using the latest version of IntelliJ (2017.1.3) and used the process described above to create the artifacts.
My manifest file are not copied to generated jar too. It is located at META-INF/MANIFEST.MF. These manifest was defined at Project Settings -> Artifacts.
Another problem that I perceived while I was investigating this problem and can be related with this, is that if I create the sample JavaFX app and move the Controller class to a controller package and sample.fxml to a view package letting the Main class alone at sample package the application will not run anymore and an error will be launched at start up of app if I try to use terminal to launch the app using the generated jar (java -jar javafxapp.jar).
Hi to all,
I am having the same problem even when I create a simple java project like a command line app or a java hello world.
Error: Could not find or load main class com.company.Main
What can I do to solve the problem?
IntelliJ IDEA 2018.1 (Ultimate Edition)
Build #IU-181.4203.550, built on March 26, 2018
Licensed to Luis Ribeiro
Subscription is active until December 2, 2018
JRE: 1.8.0_152-release-1136-b20 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
With best regards,
Please refer to http://stackoverflow.com/a/42660624/104891.
GOTO Run->Edit Configurations
Ensure that Main Class value is set properly.
I once refactor my package name from 'sample' to 'somethingElse' and then i found error => classNotFound
It was because I changed the package name, but the change was not made implicitly here
Gitwithravish - Thank you. This really helped me out. I was having a similar issue after renaming a package.
in my case helped deleting this line from the file build.gradle
compile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '8.2.0.jre11'
I don't know why this happens, but after adding the specified library, the compiled jar stops working
Mark Smirnow87 https://stackoverflow.com/a/45169655/104891 is likely the case.
Serge Baranov thanks, but in this case, there must be a way for gradle to automatically remove the signature and manifest from dependencies...
and it's strange why in this case there are no build errors, it just doesn't work without any warnings
Mark it's easy: https://stackoverflow.com/a/51456080/104891