maven main class not found

Well, I had this problem and after seeing this post and particularly khmarbaise answer I noticed that M2_HOME was, I would like to mention that I use windows 7 (x64). Here is some of the code with the main: I posted this before but had a couple issues. Many thanks for the tip, now I can run hdbpp-viewer. For a java programmer it shouldn’t be a big trouble to debug a script around 20 lines, even if it is a little bit alien language. What does “Could not find or load main class” mean? I have been searching for a solution for hours when I stumbled on to my solution (I say my solution because I know this probably won’t be the solution for everyone that is getting the same error). I opened a cmd window and typed cd and pasted the path I got from my M2_HOME variable. First off, if you are running your entire project and not just the current file, make sure your project is the main project and the main class of the project is set to the correct file. Once you carefully do the setting of these 3 variable, you can verify Maven’s installation as below. I'm afraid I haven't used NetBeans much, so I can't help you with where that option is. The response is a sheet file, how do I decode it and read it in springboot Java ? © 2014 - All Rights Reserved - Powered by, Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher. Thank you. I noticed that Maven Source zip didn’t include any libraries at lib folder however Binary zip had them + in boot folder it had plexus-classworlds-2.4.jar. Asking for help, clarification, or responding to other answers. The solution for later versions of Maven is straight-forward. What could be the problem? Were any IBM mainframes ever run multiuser? This is a common issue while setting up Maven. The mvn command, is a script. Even though the question is answered I would like to add that, if you are getting the above mentioned error, be sure that you have downloaded the Binary file. I am getting a message that says "No main class found" when I try to run it. public static void main(String[] args). My best guess is under "Run Configuration", or something like that. The source file should only be downloaded if you are an advanced user and that you know how to deal with it. The connections I made in preparing this for posting really cleared it up for me, once and for all. (project created: New > Java Class > Named it 'Whatever' you want, Click on Run > next to 'Main Class' text box: > Browse, Copy your current code (or back it up in a different location), Create a new main class in your project (you can name it the old one). In the project properties I had to set the launch configurations to the file that contains the main-method (I don't know why it wasn't set to the right file automatically). I have read and tried all the solutions given at blogs such as : but still not able to get to it. Hope this helps. javascript – window.addEventListener causes browser slowdowns – Firefox only. I meet this problem just now, no method work after searching and searching. 19. Thus, if you write: mvn install, what will happen: The problem is with (2). I too have the same problem and followed your steps. I am on OS X ElCap, 10.11.6 and upgraded to Maven 3.3.9. Questions: I am setting a textview as HTML retrieved from Firebase database. It started working ! Look for Main Class. When creating a new project - Maven - Java application in Netbeans Were English poets of the sixteenth century aware of the Great Vowel Shift? (in Step 8 below we see no classes). Try adding try/catch blocks instead of using the throws declaration and try again. And run again. You should change the location of the M2_HOME into the following: Furthermore the installation of the JDK looks more a JRE instead of JDK. D:\sample>java Example This is an example class Is Elastigirl's body shape her natural shape, or did she choose it? – Stack Overflow. Press the hammer to the left of the green arrow (run), for the program to clean & build project. if all that is your code you forgot to close the main method. It will open project properties.In the categories select RUN. So, instead of mvn install, give the command bash -x mvn install. It make which work finely, and novices get stuck. It needs also jcalendar.jar and jython.jar, but I think that I can found a way to use the Debian version instead of the ESRF jar files. I am only posting a bit of it because it is a class assignment. It's not completely obvious what goes in the Main Class: box until you see the connections. You need to rename your main class to Main, it cannot be anything else. Finally I created a jar and war file and my web app ran successfully on my local Tomcat. But still the problem persists. It look like that you have installed Source files(Because src only comes in Source Files and we don’t need it). Select Main Class. Can everyone with my passport data see my American arrival/departure record (form I-94)? Besides what @khmarbaise has pointed out, I think you have mistyped your JAVA_HOME. I was having this same problem and was able to resolve it by carefully redoing the Environment Variables: Also, I made them all System Variables, not User Variables like the Maven instructions say. For a mavenS W project that features "jar" packaging, we can specify the main class for the MANIFEST.MF file by specifying it in our pom.xml, as shown here: pom.xml For other people who might run into this, don’t forget to check ~/.mavenrc for M2_HOME or JAVA_HOME settings. On windows, you have to find some other way to debug a cmd.exe script. In that go to Build Path, … Note: Please delete M2_HOME, if already set. The problem is solved. Any advice will be greatly appreciated. Then add the bin directory of the created directory apache-maven-3.5.0 to the PATH environment variable. Path :- This can be the System Variable OR the USER / ADMIN variable [PATH]. Posted by: admin I went to that path via Explorer and sure enough there were files present. : Had this issue on two different Ubuntu 12.04 installs, despite the installs being done by apt-get. D:\sample>java Example.class Error: Could not find or load main class Example.class Caused by: java.lang.ClassNotFoundException: Example.class. I finished my project and it worked fine. It sounds like you installed (extracted) the source files instead of the binaries based on your path information. I have found that was wrong: hdbpp-viewer needs the Java HDB++ Extraction Library. The link provided here offered the solution in a comment by McKamey – simply delete M2_HOME (unset M2_HOME). @assylias - I just hit the green play arrow. If the advice to add the closing braces work, I suggest adding indentation to your code so every closing brace is on a spaced separately, i.e. I also experienced Netbeans complaining to me about "No main classes found". Installation Path : In the command window it shows it like this: This is the only version on maven installed on my PC and the solution given on many blogs referring to the deletion of the previous M2_HOME environment variable is not valid. At the end, you can easily test, which environment variable gone bad, and you can very easily fix your script (or set it what is needed). What I might be missing in this whole thing? Leave a comment. But in my case I used apache-maven-3.3.3-src folder in path variables. Sometimes, in Netbeans, a simple fix is to: If this doesn't work then try to clear the Netbeans cache, and if all else fails, then just do a clean un-installation and re-installation of Netbeans. Package name without in maven. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Why? this script sets the needed environment variables. I am working with NetBeans. mypackage.MyClass). When first a generic class is created and then the Main class is created Netbeans is registering the Main class and the app could be run and debugged. If you just want to run the file, right click on the class from the package explorer, and click Run File, or (Alt + R, F), or (Shift + F6). By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. Do you have any other classes in the project aside from LuisRp3? Maven is a command-line java tool. I have Windows xp box and when I would type mvn -version at the command line prompt I got the dreaded error message. and when I tried to echo M2_HOME from the terminal, it showed me the correct path but when I tried to fire any maven command like mvn clean or mvn install, it always gave the same problem, Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher, I solved this issue by changing my M2_HOME to this, And voila ! Press green arrow. And then set environment variables as described there. I copied the path that was assigned to my M2_HOME variable. C:\Documents and Settings\ADMIN>mvn –version, Apache Maven 2.0.11 (r909250; 2010-02-12 11:25:50+0530) Java version: 1.6.0_22 Java home: C:\Program Files\Java\jdk1.6.0_22\jre Default locale: en_US, platform encoding: Cp1252 OS name: “windows xp” version: “5.1” arch: “x86” Family: “windows”. Solution − The extension .class is not required while executing the program. I ended up closing and reopening my project and it then found the main method. Right click on your Project in the project explorer, Make sure your Main Class is the one you want to be the entry point. Why is the concept of injective functions difficult for my students? Am not telling that is the same error reported here but this way also you can get this error and rectify it. Making statements based on opinion; back them up with references or personal experience. Why did MacOS Classic choose the colon as a path separator? javascript – How to get relative image coordinate of this div? In my case I forgot the args. Fortunately, this script is simply, very simple. It could be that your main method does have the proper signature. There could be a couple of things going wrong in this situation (assuming that you had code after your example and didn't just leave your code unbracketed). How to highlight a "risky" action by its icon, and make it stand out from other icons? That means, it is not a standalone binary, it is a collection of java .jars, interpreted by a jvm (java.exe on windows, java on linux). Edit: See peeskillet's answer if adding closing braces doesn't work. When I am setting the question the I am adding another value called qid to the textview. My specific failure reasons probably differ from the OP, but I'll still share what I learnt on the debugging journey, in-case these insights help anybody figure out their own unique issues relating to this topic. the IDE is not recognizing the Main class on 1st class entry. The modifiers public and static can be written in either order (public static or static public), but the convention is to use public static as shown above. What happens if someone casts Dissonant Whisper on my halfling? When you. But the output comes in 2 lines. So it would be. Next I tried the mvn –version command again, but this time I got back the expected results. your coworkers to find and share information. 使用maven打包时,提示maven打包时,提示main class not found,解决方法:pom.xml中增加如下配置: org.springframework.boot spring-boot-maven-plugin