I have a big project and i decided to change some of the packages inside and also rename and delete some classes.
After I did it I am getting an error of:
java.lang.ClassNotFoundException: Main.Ser_Network.
That class does not exist anymore and i have replaced it with a different class and changed all the references to it inside the project.
I have also tried Project --> Clean.
Nothing works and i don't know what else i can do.
EDIT
I created a brand new project, created new packages and new class file (same names) and i am still getting this error.
How can i solve this issue? This is very important, any help would be appreciated.
Thank you.
Make sure that all references to the class are not in your code. You can do this by searching for it with a Ctrl+H.
Also try right-clicking your project folder and clicking "Close Project." Then try re-opening your project and rebuilding.
Related
I am trying to create a new java project in my workspace. But i am getting the following Error:
"Overlaps the location of other project"
My current projects in:
Documents/workspace/Folder/{projects(About 10 Projects)}
If i create a new project from Eclipse, the new projects are coming under:
Documents/workspace/{New Project}
I have tried to the following steps to resolve this mentioned in other posts in stackoverflow.com:
Eclipse: Error ".. overlaps the location of another project.." when trying to create new project
But i am not able to solve this. Can anyone help please?
Ok, I fought this issue for a day and feel quite humble when I finally read all the post and figured out a good solution. This should be added to an Eclipse ten commandments... Thou shalt separate your workspace from your code and never the two shall meet. In that create the folder structure something like this:
C:\workspace\training\
C:\training\maven102-section1-initial-master\...
When you open Eclipse, point your Work space to the "c:\workspace\training" area. And for all your code, keep it in the "c:\training\maven102..." area.
My issue was having EVERYTHING ALL in the same folder, like a big old hoarder... and that does not work out either. Enjoy!
I have a project in intellij and when I created my packages I made a mistake because they all start in capital letter, for example my previous package name was "Main" then I changed it to "main" and I did it to all of my packages.
error: package com.myproject.thesis.main does not exist import
com.myproject.thesis.main.Main;
but the "main" package and "Main" class does exist and already imported on the class that needs it. Also what should I name the package where I put my main class?
While it may not help in this case, a general thing to try when "My code compiles and runs, but IDEA is really confused about the symbols in my project" is to go into the "File" menu and choose "Invalidate Caches / Restart". I've rarely used it, and it doesn't always help, but every once in a while it fixes IDEA's confusion.
See also the IntelliJ IDEA help on Cleaning System Cache.
You need to edit configuration. From IntelliJ Run menu choose Edit Configurations. On the configuration window change the package name of Main class.
I hope this helps.
Try changing the packages to something else first. e.g. coma.myprojecta.thesisa.maina and get that to work. Then change it back to com.myproject.thesis.main. I think IntelliJ might be having problems with the change in case. If you change it something totally different and then back it IntelliJ should realise that things have changed.
As for what to call the class with main method, it is up to you. There is some good advice here. https://softwareengineering.stackexchange.com/questions/208062/naming-conventions-for-java-classes-that-have-a-static-main-method
You could also try a complete reset of the project. Create a whole new project, with the packages named (and cased) the way you want. Then, move the code files from your old project into the folders for your new project. IDEA should be able to see the files you put in there and parse them correctly.
Just clean the contents in /target (or "mvn clean"), and Intellij can find your new package correctly.
When I create a new class inside a package for some reason it creates two class files: one inside of the package and one out of it. I wanted to know why this is happening? Also, at times, Eclipse are kind of "hiding" some of my classes, so that they do not appear in the project explorer, although when you create a new class file with the same name of the class that disappeared, it says the class already exists...
When I refresh (F5) the package, these problems are sort of solved. But they happen again when I create a new class or when I restart Eclipse. So I wanted a different solution from keep pressing F5 everytime...
So I had this same problem and it may be for the same reason. The problem can be because you are creating the .java files in the Project Explorer window. Close this window. Then, go to Window -> Show View -> Package Explorer. Then create your .java files there. The issue is that the Project Explorer window looks EXACTLY the same way as the Package Explorer.
#Rammohan's answer helped me but I can't vote it up or apparently add a comment because of low reputation. Being new to Eclipse I didn't get what he meant at first, so wanted to add a little detail for other people.
From the top menu it's Window -> Perspective -> Open Perspective -> Java.
I had unwittingly switched to the Debug perspective and had the double-creation problem happening in src/test/java (but not in src/main/java, still don't get why). Switching to the Java perspective cleared it right up.
I also had same problem with eclipse. This issue is resolved after changing Perspective mode from "Debug" to "Java". Two same class files appear when Eclipse Perspective is in "Debug" mode. In "Java" perspective, this issue is resolved.
Hope this helps if someone facing same issue.
Unfortunately I deleted the main class of my netbeans project. Now running my jar file is showing error as "Could not found main class". What should I do? how to rebuild main class. My project Name is "netbeans1" having Source Package that consists "myproject1" as subpackage.myproject1 consists all the form of my project.Should i make the main class for netbeans1 or for myproject1?How to make it? Please help. Your help will be appreciated !!
You can try like this,
Right click on the folder/directory that the files had been deleted.
Choose Local History – Restore Deleted
Done
I am building an application and I added a new activity to generate a view. I compiled it. My application can not find anything that is on the format R.id.xxx or R.layout.xxx, I've tried also cleaning my project, closing Eclipse and opening Eclipse again, but nothing. The most strange thing is that before everything was working well. But now it can not recognize even the R.layout.main that is default of my principal activity. Anyone have an idea?
Also I have tried almost everything here: R cannot be resolved - Android error
but no result!
Solved
Thanks to woopsy, also I found the reference to this kind of problem
http://source.android.com/source/using-eclipse.html
it happens because Eclipse sometimes imports R when you press the combination ctrl+shift+O
Remove all your imports for the Activity and then have eclipse fix imports. I have had problems where eclipse wants to import a different R than the one I need.
First of All Check You have R.java File then check
import android.R;
Enter Yourpackages like import com.mypackages.prj;
If you are using eclipse, take a backup of your layout main.xml file and then from the eclipse new file interface create a new "Android XML File" and call it main.xml. copy back from the backup the contents into this new file.
try this.
check your xml files. there might be something wrong in it which is causing R not to build up automatically. To observe such errors, switch your view to Console tab
this is a common error. You need to just search your R.java file in generated section of your project directory in Eclipse. Need to import if the R.java file into the package then import . R;
I hope it will work for you. It was absolutely worked for me...enjoy programming
friends take care that u haven't imported R class, if you have delete "import android.R". The reason is there are two R things one R.java and R.class and we need the java, where we dont need to import rather than referring it. It worked for me and may be to you too.
I found the solution...For me works it
Poject->Properties->Android->Project Build Target (here choose android4.4 or 5.1.1 Android Open Source Project)->Ok
Project->Build All
This function ...
This problem can fix with this process: -
File---->Invalidate cache/restart.
it will restart your android studio and fix that problem