I am very experienced in Java, but not in Netbeans. I have a project that I've been working on, a little test program for a particular issue, so I have been making changes to it and running it and debugging it many times a day, every day, for several weeks. Yesterday Netbeans quit running it the way I had been running it, and I can't seem to get it started again.
The entire output when I run the project is:
run: Error: Could not find or load main class
C:\Users\rcook\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
I note for whatever it's worth that the classname does not appear on the first line, as it seems to with others who have had the "could not find" error.
This happens whether I run the project (select the project and press F6) or the file (select the file and press control-F6). I have cleaned and rebuilt the project (which I didn't do often before, I've wondered if it caused the problem). I have restarted Netbeans. I have restarted the (Win7) computer. I am not running any memory-hogging programs except for Outlook, which I have been running the entire time it was working.
I can run the program from the command line by setting my default directory down to the 'classes' directory under the project and entering java stsclientexample3.STSClientExample3.
I have checked the "Run" configuration many times -- there are no program or VM options entered, it has the correct classname. Oddly enough, if I change the classname to something that isn't there, Netbeans displays a popup that says the invalid name class wasn't found in the project, and listing the main classes available. But when I do that and select the one to run, it gives the same "could not find" error. There's one other main class in the project, if I select THAT it gives the same "could not find" error.
I have looked at the XML file referenced in the message, but it is full of ${parameter} references that I don't know the resolution of. It would likely be helpful to know how Netbeans resolves "${classname}", for instance, or even to dump the value Netbeans has at runtime somehow.
I have commented out code and re-run. Same result.
I have deleted that class from the run configuration, restarted Netbeans, and added the class back. Same result.
By now I've read more than a dozen other queries for a similar error, on SO and other places; I've tried all the things that looked at all possible (skipping things like configuring for special-purpose libraries, etc.).
Anyone know how to fix this?
EDIT: before someone asks, another project with a main() runs using the 'run project' option.
EDIT2: I forgot to mention, also, that another post recommended that one delete the Netbeans cache (c:\Users\\AppData\Local\NetBeans\Cache), so I shut down NetBeans, deleted everything in that directory, and restarted NetBeans. Same result.
I've encountered this problem a few times and it is very frustrating. If you delete the cache it should fix it after you rebuild the project
Close netbeans
Delete the Cache folder User\AppData\Local\NetBeans\Cache\ (Windows 7 and above)
Open Netbeans
Rebuild and run
Edit - you can find the cache directory also by going in netbeans to Help - About then it shows your cache directory.
Try creating new class with main method and copy your code into this class.
Just close the Netbeans. Go to C:\Users\YOUR_PC_NAME\AppData\Local\Netbeans and delete the Cache folder. The open the Netbeans again and run the project. It works like magic for me.
(AppData folder might be hidden probably, if so, you need to make it appear in Folder Options).
I'm working in the Netbeans IDE 8,2. I had the same problem and in my manifest.mf, the field classpath: was empty(I noticed that because I got the message:
java returned 1 could not load main class ExerciseFinal
I looked at the classpath nb where searching and I simply changed one folder's name and then after restarting netbeans everything worked.
My file name was "teo_1=1;" and I changed it to "teo" simply because I thought that maybe 1=1 (always true) was messing the nb.
I had the same problem and i think the problem was in the file path, either it was too long or it had some forbidden characters(now i have seen that it was a letter from my language), when i copied a project to a different folder it worked...
After an eternity of trying to figure it out myself, looking through every menu, submenu, tab, and option, I was still stuck. Nothing anybody suggested worked for me.
How many hours did I spend flailing about in the name of pride and self-education? Several. How long did what I'm about to suggest take? Maybe 10 minutes; 15 tops.
Was my journey a waste? No. I learned a lot. But since I hadn't set out to learn what I did and was prevented from work I needed to do, I was pissed long before giving that up and copping out.
So... Long story short, do this:
(Step 1 has been deleted; renumbering steps might be bad idea. So start with 2!)
Step 2: Open the problem project.
Step 3: Create a new Netbeans project, get into Project view, and expand both projects to show their packages.
Step 4: Thoughtfully copy all packages from problem project to new.
(This means to hold off on the "main" package until last to avoid a chuteload of red-marked errors. If you see a bunch anyway, don't look at them. Further copying will fix many.)
NOTE: Having to choose a different project name for the new project will likely lead to a new name for your new "main" java class file. No problem. Just note this.
Step 5: Once you've copied all but the "main" package from problem project to new, open the "main" package to see your files. Then open the new "main" package, which will have ONE tiny file in it.
Step 6: Thoughtfully copy one file at a time (holding off on the "main" class file until last) from problem project to new.
(If you see errors, let 'em go. Not finished yet.)
Step 7: Once you have only the "main" class file left to copy from the problem project, open it. Also open the new "main" class file in the new project.
Step 8: Copy all the code from problem project "main" java class file and paste it into the new project's "main" file.
Step 9. There will be errors at the end. After all, at least one package and one file name changed. So open each source file with an error, put the cursor on each line with error, and press Alt-Enter to get a hint. Renaming the new main file or changing some old package names to new will fix a few, especially in some imports; this might just get rid of the rest.
I hope this helps someone. I should look for a more recent post and put this Answer there, if it gets enough upvotes.
Related
First of all, this is my first ever post on stack exchange so let me know if this belongs in a different section.
Anyway, I've been wanting to get into modding minecraft so I downloaded JDK, Forge MDK and eclipse neon. After exacting files to a separate folder, I created a path variable and a Setup Workspace.bat file. In that file I typed
gradlew setupDecompWorkspace && gradlew eclipse
After this, I ran it and it got to 56%, or decompilemc. It stayed there for about 6 minutes before the console crashed. I assumed there was an error so I researched it and tried to fix it by adding more RAM to the gradle.properties. That didn't work either, so I continued researching for about an hour, and finally found something that made it go pass the decompilemc, only to break again at recompilemc
Have any of you ever encountered this problem? If so, how did you fix it? Any answer is greatly appreciated.
If this is your first time starting a Forge Workspace, make sure you have the "gradlew.bat" file, then simply shift-click your home directory and click "Open command window here". Then type:
gradlew.bat setupDecompWorkspace eclipse
Or if you're using Intellij (Which I suggest you use over Eclipse):
gradlew.bat setupDecompWorkspace idea
That should start the process of generating your Workspace.
Surprisingly useful is the fact that it can run multiple commands from one command statement. Meaning that you can type both "setupDecompWorkspace" and "eclipse"/"idea" and it will run both separately one after the other.
I have been working on trying to use the openLogger tool which uses the OpenLog Database also available at openNTF, and I have hit a bit of a snag. My question is not about those databases explicitly, they are just a good example of what is going wrong!
My issue is that I wanted to rebuild the OpenLogger Demo/test database after making a few changes to the xsp.properties file, and I suddenly was presented the wonderful gift of 12 or more errors, all of which were that the com.ibm.xsp.extlib.util.ExtLibUtil class could not be resolved.
After a bit of googling, I found out that it sometimes helps to re-install Designer - done (three times)or to re-install the ExtLibs (done a few times and then upgraded to the 900_201305* version)
nothing.
I have really tried everything I can think of, and everything that I could find via google, but I cannot figure out how to get this thing to resolve. I remember once upon a time having to copy specific jar files into the designer install directory, but I cannot remember the details, nor can I find anything about that, nor do I know if this is my issue. I also thought about a specific designer variable not being set that would tell designer where to find the jar files, but I would not know where to begin searching for that.
Any help getting this thing to resolve would be a HUGE! help. It could also be that I wish to use this awesome looking class in my own applications. Thanks!
To make sure that the jar files is found and able to be used, try these things:
Use the package explorer to make sure the jar is in the "Referenced Libraries" folder
Check the build path, and add the jar to the build path if necessary
Examine the XSP properties file and make sure it looks correct, and then change something and resave it
Use Project | Clean which sometimes fixes issues like this
Today I came to work, happy. But when I opened my Eclipse, I saw that one of my projects has errors.It's weird because it shows that it has errors only in the window bar, and not in the Navigator. I don't have any Java errors, this is a valid project that was fine all the time:
Some of the errors on the error log of Eclipse:
JavaBuilder handling ImageBuilderInternalException while building: SP_Procedure
Cannot connect to VM
File <SomeFile> has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Internal error
When I run an application from this project, I get a warning message but when I proceed, it works fine, but still. It's very disturbing and I'm not sure if it's harmless.
I tried to:
Restart Eclipse
Restart my machine
Clean projects and recompiling them.
Refresh projects
Pray
Nothing helped. What could be the problem? (I'm using Indigo Service Release 2)
The following nuclear option has desperation written all over it. But I have been where the OP has been with the Juno version of Eclipse.
Run a "Synchronize with Repository" and save all of your local updates to a different directory.
Delete the project. (Check the box to delete the contents on disk. Scary step, but that's OK, because you saved it in a different directory in the previous step, right?)
Read in a fresh project from the repository. It builds happily at this point.
Integrate your local updates.
Keep on praying.
Looks that one unused JAR was deleted, but for some reason, I didn't get errors in any file, even in the files that imports this JAR! So what I did was restoring this JAR, delete unused imports and deleted the JAR again.
I've found this error after two days of navigating on this project on each file.. This is weird that Eclipse didn't recognize that1 this is an error, and throw many unrelated errors such as:
Cannot connect to VM
File has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Is this a bug in Eclipse? (All errors and warnings are enabled!)
1 As seen in the image in the question..
A class from the list of imports for the file seems to have moved out or the jar file containing the class is missing.
Expand the imports section and check if you find some classes that are missing but have been imported.
Though it is a pain, sometimes the easiest solution is to back up all your projects (either in a repository or somewhere else on your computer) then uninstall and reinstall eclipse. No it's not fun, but it should reset eclipse so everything works again. The downfall though is that you have to reconfigure eclipse to any special settings you had/reinatall any extra functionality currently installed (eg. android add-on) and reconnect to any repositories you have. While punting isn't fun, it can be effective... I hope you don't have to resort to this though.
I have went through that problem a lot of times, and tried everything you tried. Rebuild, recompile, refresh, remove and add JDK, remove and reinstall Eclipse... nothing worked
The only thing I concluded is that the workspace metadata was corrupted.
What I did (every time it happened) was
Create an empty workspace
Import -> existing projects into worskpace
Mark the "copy projects" (else it will only link them)
Wait for the copy, and start working with the new workspace
If you work with SCM systems (Git, SVN, etc), making a full checkout will do the trick too, but the worskpace import will let you retrieve those changes you didn't get to commit (if any).
It's a little painful if you have somethings already set (like JDK names, servers, etc), but then I realized it was faster than keep searching how to fix the workspace
Regards!
PS : I've been working with Kepler lately, and everything works fine till now
Click Window -> Show View -> Other -> General -> Problems
This view will show you what is wrong.
Did you, by any chance, update your virtual machine outside of Eclipse? I can't help but feel that we're both missing a finer detail here. I just keep seeing "cannot connect to VM" and thinking that it's a major clue.
Have you tried running anything from the terminal? Does it work there?
If so, do you know where your current edition of Java is located? Is Eclipse looking somewhere else?
Is this exclusive to one project? Do you use any additional libraries to the JDK?
Maybe try this for Resource is out of sync with the file system error:
Right click project in Eclipse Package Explorer
Close Project.
Right click project in Eclipse Package Explorer
Open Project.
Other things not mentioned:
project properties > java build path, see if any of those tabs got changed, local file got moved? read/write permissions on some file you are linking to?
project properties > java compiler, see if workplace settings have changed? maybe under errors/warnings, you can systematically set them to 'ignore' until the error goes away to determine what type of error it is?
maybe update some of the eclipse plugins?
I saw something like this happening for a number of reasons. Mainly because of validation in files other Java source code. See if you are validating XML for instance.
Right click your project and chose Properties (Alt+Enter) and Validation to see the related configuration.
As for the danger, I lived with those marks for ages and nothing wrong ever happened.
I've been searching the web for a long time, and it seams that this VerifyError isn't that uncommon and can have multiple reasons for tripping. I have created a project, that I've exported as a jar file. It is built with android 2.2 (API 8). This part works fine. But I have a separate project that when I try to import it, I start having problems.
The only way I've been able to get it to work, is to import the jar into a libs folder I created. It then get's automatically added as an Android Dependency and I can use it fine, however I can't attach my javadoc file to it, and in my build configuration it says I can't modify the dependency. (Can't link to a javadoc).
What I thought I should be able to do is simply add it as an external jar, then link the javadoc and source. If I do this, the code that uses the jar shows no errors, and the javadoc comments work. However I keep getting a VerifyError when I run it. I've attached a stack trace that shows the errors. I'm completely out of ideas, does anyone have any suggestions? Am I building the jar file wrong? Am I importing it wrong?
If anyone can help point me in a constructive direction, it would be really appreciated.
Thanks
Stack trace:
Ok, so this was frustrating to solve. The solution took about 20 seconds when I spent over an hour researching the problem.
What I had to do was go to:
Properties -> Java Build Path -> Order and Export
But rather than just clicking the external jar, I had to move it up to the top of the list for the build path order.
Credit definitely goes to yorkw for pointing me in the right direction.
I believe that Android jar files are a little different.
You could try putting the JAR files into the Android "dx" tool
It's in the ~/android-sdk/platform-tools
I'm trying to help another developer who is using Netbeans. When he runs or debugs some code of his in Netbeans (6.9.1) he gets an "Uncompilable source code" RuntimeException. I'm pretty experienced in Java but am more used to IntelliJ, and haven't used Netbeans at all.
I've done it a bit of googling and it seems Netbeans will compile code even with errors, and then throw the RuntimeException at the errors. (Fairly bad behaviour IMO, but I guess some will find it useful.) I've got him to completely rebuild the project with no compile errors, but the RuntimeException seems to still occur. I assume he's got some bad cached class data somewhere deep within Netbeans.
2 questions:
What is the best way to clear the cache so we can find out where the uncompilable code is?
Is there any way of turning off this behaviour so the code won't run/debug unless everything will compile, so these RuntimeException's won't be injected into the code?
I've googled a fair bit, but haven't found the answer to either of these questions yet.
Update: More information:
Turning off the "compile on save" option makes the problem go away. Turning CoS back on again brings the exception back. Unfortunately this isn't a fix, as CoS is a very useful option.
http://netbeans.org/bugzilla/show_bug.cgi?id=182009 seems the closest bug report, but it has been closed as "RESOLVED INCOMPLETE". Unfortunately the bug is hard to reproduce - the exception is happening in Java library code, when it calls a third-party library, so there isn't anything at the point the exception is thrown we can change. And the code will work for weeks, and then suddenly start throwing this error with no obvious reason why.
We've tried manually deleting the entire build directory - still not a fix.
We finally got a solution, but still don't quite know why the situation occurs. When you have Compile On Save activated, Netbeans generates a second set of class files for debugging etc. These are stored in $USER/.netbeans/var/cache/index/s*/java/*/classes
Somehow (not sure how) this directory can get corrupted or fail to update.
If you close netbeans, delete $USER/.netbeans/var/cache/index and all subdirectories and restart netbeans this clears the cache. If you have no compile errors, your problem ought to go away at this point.
NB: $USER is your user directory - on Windows 7 this is usually c:\Users\username, I guess on Unix it will be ~username.
If you get this problem please vote for, comment on, or add information to: http://netbeans.org/bugzilla/show_bug.cgi?id=182009
I experienced the same wired problem in NB 7.0.1, my hammer-IQ solution was to make a typo in the source code, run NB with this error (despite an error message) and than the cached class was successfully deleted.
I experienced this issue on Linux Mint Nadia with Netbeans 7.2.1, but was stumped as to where the cache location might be - mine was actually located at
/home/USER/.cache/netbeans/7.2.1
rather than in the .netbeans folder.
If you're not sure where the cache is located on your particular setup, just go to the help > about menu in Netbeans and it'll tell you the correct path.
After realising that the cause was a bad cache from the other posted solutions, I solved this problem by copying the file to another directory, deleting it from NetBeans, and then adding it again.
In fact, you neednt delete whole of index folder.
When you open netbeans and your project folder is active. Netbeans starts scanning files and creates temporary project folders (in index folder) for all active projects. If you check index\segments file(its a text file and can be viewed in notepad/(text editor)), you will be able to identify the folders that represent your project. You can then delete those folders and restart netbeans.
*Active project means those projects that were open before Netbeans was shutdown.
Had the same problem on Windows 7 with Netbeans 12.
Cache is here:
C:\Users\<Username>\AppData\Local\NetBeans\Cache
, but the deleting cache is not helpful sometimes. The better solution is to recompile the problematic class i.e. make a minor change (e.g. add space) and save.