Category: Class not found in intellij

By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. The following piece of code keeps does not even compile and keeps giving me the error:. Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything. For me the solution was to fix the output directory under project settings.

Before I was using just "target" for the Project compiler output. Instead I updated it to have a full path e. None of my Java classes were being picked up after I pulled from a remote branch.

All the classes had red Js by their names in the Project Hierarchy, not blue Cs. Invalidate cache and restart your intellij, it worked for me. This is probably easiest done by clicking on the class name in the left-hand side Project Pane. I know this was asked a while ago, but I was just stumbling over this issue and thought my findings might help others.

As pointed out, the error message is basically a result of the out folder. That's because, when you're trying to run the program, it compiles the code first, and puts the compiled result to the out location, and then it tries to load the compiled code from the out location.

class not found in intellij

If the compiled code is not in the location expected, you'll get the error. The point I'm particularly wanting to share is that some times, the code is not compiled builteven though your run configuration specifies "Build" in the "Before launch" section of the configuration panel. When can this happen? One situation that can cause this to happen is if you're using modules and you manually delete the module out directory.

If you manually delete it, the build system may not know that it needs to be rebuilt. Even worse, if you select Build Build module 'foo', it still may not rebuild the module. If that's the case, you should select a file in the module, for example 'bar. Since IntelliJ typically knows about any changes going on, this surprised me, and took me a little time to figure out, so I thought I'd share. I had to mark the "src" folder as "Sources". After restarting IntelliJ and rebuilding the project I could run the project without further issues see screenshot.

I had two modules under one project. I've solved the problem after removing the second redundant module see screenshot. I have faced such problems when the class is in the default folder, i.

So I guess using a package statement eg. This should fix the problem. Also check latest language is selected so that you don't have to change code or do any config changes. In my case the problem seemed to be related to upgrading IntelliJ.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

I know, it seems pretty obvious what the problem is, but having spent too much time on this problem I now turn my trust to you! I use ideaCommunity-9, where I have created a global library for JBoss, which contains all JBoss jars including ejb3-persistence. My module includes this library, and I have moved it to the top of dependencies. No otherwhere in classpath I have a javax. ManyToOne class, and it also opens up in IntelliJ without problems.

The code is also build with ant and here it works fine. Besides the above error I get six others along the same path name in Table, etc. I also get a message saying "Please file a bug to JDC yada yada yada. You should also see a checkbox near each lib in column 'Export'.

Just got this myself but non of those things were my issue. I downloaded a project from github, then opened in intelli J with the problem after trying to run a junit test. This should highlight src to be blue and all the class files should be the circles with C instead of looking like normal files.

Try running a test again and see if that does it. I'm sure, it is too late to answer, but I had to follow a different approach for this error to resolve this issue. I had to create this as global library and add that library to the module, then only the error is resolved. Isn't that similar to this SO question?

class not found in intellij

The solution there was to add all JBoss jar which you didbut also all persistent-related libraries like Hibernate. See this JBoss project configuration for example:. In short, ejb3-persistence. Or, if it is the problem, it may be related to the fact that it is not deployed correctly for the WebApp configuration.

Here's an idea: Maybe you have multiple versions of your jar file. Search your folder hierarchy for the file ejb3-persistence. Multiple appearances of the file in your classpath may confuse IntelliJ Idea into not recognizing the proper class in the proper jar. DefaultResourceLoader even though it was in my maven dependencies and no amount of tweaking of revalidating caches seemed to help. At least for now I was getting the class not found error message when trying to execute a.

The reason is, I had changes in other files in the same maven project, that were not getting picked. Learn more. Class file not found in IntelliJ Ask Question. Asked 10 years, 8 months ago. Active 2 years, 2 months ago.

Viewed 59k times. In IntelliJ I get this weird error when I try to compile.

class not found in intellij

Cannot find annotation method 'cascade ' in type 'javax. ManyToOne': class file for javax. ManyToOne not found I know, it seems pretty obvious what the problem is, but having spent too much time on this problem I now turn my trust to you! Yes I have no problem viewing the class file for ManyToOne.I am having trouble with a simple Java project. When I look at the actual invocation in the console output, I do not see the module directory on the classpath. When I look at the run configuration, the main class name and the Use Classpath Of Module look correct.

Nothing is red. I'm sure this is something simple, but w here should I look to find the problem? Could you please prepare and provide a small sample project illustrating the problem and the exact steps to reproduce complete zipped source tree and project files? I don't know how to create a project that has this problem. All I know is that I have a project with this problem. I am not willing to send this project to you.

If you have some suggestions of where to look or experiments to perform, that would be helpful. Make sure it's not excluded from compilatio. Post the full command line from the Run console starting with java call, the first line that you can expand and the exact error java reports.

Ensure Make before launch is enabled and there is a compiled. Found it! But this raises more questions Why did the build not complain? If it put the class files somewhere, why did it not include that directory in the class path?

Please sign in to leave a comment. Submit a request. Sign in. Sort by Date Votes. Here Attachment s : Screen Shot at 8.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I am trying to create a run configuration for a spring boot app, but Intellij can't find the main class of the spring boot app Usually it is automatically populated.

I tried adding the class by searching the project structure, but Intellij won't let me add that application's main file to 'Main class' of the configuration. How can I make Intellij detect the class? I had similar problem.

Subscribe to RSS

The same issue occured to me. In my case, it was the project JDK that was not set. The module JDK was set, but not the project one. I had the similar issue. After save it, I was able to add the Spring Boot configuration as usual. Thanks AlminaS for the lead.

class not found in intellij

I had the same issue. Then rebuild the pom. Learn more. Asked 2 years, 10 months ago. Active 2 months ago. Viewed 9k times. Idea will also check that the class has a valid main method.

It also needs to be within the selected module. Generic yes, I set the parent folder of the spring boot application as the content root. Do you have the Spring Boot plugin installed? Also check if you have the classpath of modules set as your project in Run Configuration. Rakesh I do have SpingBoot plugin, but I do not have classpath of modules set. It does not let me set the classpath of modules - there are no options in the dropdown.

Active Oldest Votes. AlminaS AlminaS 75 5 5 bronze badges. Problem may be that you have badly configured IDEA project files. Close IDEA, delete all. MarekM MarekM 9 9 silver badges 13 13 bronze badges. Thomas Martin Thomas Martin 4 4 silver badges 10 10 bronze badges. Gi1ber7 Gi1ber7 8 8 silver badges 17 17 bronze badges.

Jaivardhan Jaivardhan 9 3 3 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.App Where do I look to remove or rename this? I have looked all through the project and could not find MongoDBImport. Main should only exists as Neo4jImport. Find and select the artifact definition.

Getting started with ScalaTest and SBT

Toward the bottom middle will be where the manifest file and the main class are defined. 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. We can then try and determine what the issue might be. 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 My manifest file are not copied to generated jar too. 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.

I am having the same problem even when I create a simple java project like a command line app or a java hello world. Main Error: Could not find or load main class com.

This really helped me out. I was having a similar issue after renaming a package. I don't know why this happens, but after adding the specified library, the compiled jar stops working. Serge Baranov thanks, but in this case, there must be a way for gradle to automatically remove the signature and manifest from dependenciesDear All, I have imported a maven project from a svn repository into the Intellij Idea 9.

The main project has a number of sub-projects. The projects were imported as modules in IntelliJ. Object cannot be resolved. I have configured a SDK for the module project. My question is. Why is IntelliJ not finding these class files inspite of the SDK being listed as a dependency for the module.

All input is appreciated, What am I missing? Adding the source as well as the classes will allow IDEA to provide more inline help such as JavaDocs and stepping into the code during debugging. Give the JDK a name.

In the rest of the information below, I'll assume the name is "JDK 1. Second, make sure your project has a JDK configured. Third, make sure you module s have a JDK listed. Just to verify one comment you made That would make it a standard library. It should be specified in the "Module SDK". Save your changes and you should be all set. Thank you Mark Vedder! Your solution finally resolves my issue.

Please sign in to leave a comment. Submit a request. Sign in. Sort by Date Votes. Thank you I had the same issue.

Make sure you are typing String instead of string.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Then in your simple program change package to whatever you like e. I had this problem and couldn't solve it with any of these solutions.

However I think the problem was that I was using 'open' to create a project from a directory with some java files in. Instead I had to 'create new project' with the same directory as root. Make sure you delete any '. Moving the project to a path that doesn't have those characters fixed the errors. When i changed it to "a" the program started to work. The Context is: I was trying to restart Intellij projects previously running fine.

I've tryed all solutions proposed here, but without result. At the end I just: Close the project. Shutdown Intellij. Re start Intellij, open the project previously paste into my system folder. And finaly Run my project. It works!! My suggest is: Is there a problem with pathname lenght or characters contented in that pathname to the project. I also had same problem but I couldn't find solution on web so tried rectifying myself, after reading so many blogs i understood the concept, In my case everything was fine as I have download code from git but my IDE intellij couldn't recognise maven dependencies and that's why intellij was throwing this error, my pom.

I navigated to maven window at right in intellij and added path of the project in which I was working after adding it maven loaded all the dependencies and my code worked fine. So basically only three steps can make you resolve it: 1.

Open maven window in intellij. Click Enter.

Now you can run your project. Happy coding!! Check the scope of the dependency from which the class which is shown in error stack is derived. In my case, the scope was given as provided, when I removed the scope, it worked. I've got this error when i updated Intellij Idea to But it solved when i uncheck all profiles in maven window and check proper profile again.

Above answers are fine.