[screen shot of project and error message in eclipse ide][1]
i have already made and tested a snake game in java.A siple GUI development using swing.It was running pretty fine
But when i went to create a runnable jar file i found that the classes were included in the java default package.So what i did was make a new project and copy the used resources and class.But this is the error message that shows up.
As you'll can see main is already defined in the Game play class(reffer to the image) ,hence i coudlnt think of a reason why this error message would show.
I tried changing the workspace as well but in vain,and furthermore now on running the application(with warnings ofcourse) the used resourses woulnot load!
Totally in a mess!!
could the community kindly help me fix it?
if the image is not visible try this link
https://i.stack.imgur.com/NF34x.jpg
Did you remember to include a package declaration? Remember, in order to run a java program that is inside of a package, you must include a package declaration.
Related
This is the error im getting in the console
https://prnt.sc/UEwAWFplmUWn
Here is the line its refencing on console to the mongostorage class and the onEnable that is also referenced.
onEnable: https://prnt.sc/8dnYz-VG7fL8 (the string that is not visible is "database.password")
mongostorage: https://prnt.sc/xO2DnWPeV1wJ
And here is my coreConfig file: https://prnt.sc/o900NtzQt3YJ
(Im sorry if i referenced anything wrong i just started coding and this plugin is not mine i found it on github and idk how to get it to work)
As this mention, it seems there is multiple mongoDB version on same build path.
I suggest you to relocate your own implementation.
Also, prefer copy paste and use code block instead of showing picture of code or console logs.
So I was making a java program in Netbeans IDE 8.2 and when I tried to run it, I got this error:
Error: Could not find or load main class helloworld.HelloWorld
C:\Users\name\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
(Assume that helloworld is my project name and HelloWorld is my class name)
Everything was fine before, and I can't think of what I did that would cause this error to happen. This is the first time this error has happened to me so I don't know what to do. The code doesn't seem to have any errors.
Other projects of mine seemed to also have the exact same problem even though I haven't opened or edited them in weeks prior to this error occurring.
I tried many other ways but none of them seems to do the trick. Including deleting the cache folder and setting the main class through the properties tab.
Here's a screenshot of my code with the error, my name is crossed out:
Even if I type my code directly in the main class, which is class6homework.java, the error still occurs but it says class6homework.class6homework instead of the one in the screenshot.
Any ideas on how I could fix this?
UPDATE: I got it to work by moving the folder that contains the project to my desktop, didn't know why it wouldn't work in my original location. Thanks for the help.
Perhaps you don't have the main method included. If that is not the problem, try right clicking your class in the project tree and look for an option that says "Set as main class" or something like that
Possible Fixes:
Fix 1
Go to project properties (right click on the folder of your project in netbeans)
On left tab where it shows the categories, click on the "Run" selection
Then click on Browse to find the Main class you use on your project
Fix 2
Go to C:\Users\name\AppData\Local\Netbeans
delete the Cache folder.
Rebuild and Run
Fix 3
Download most recent version of Netbeans
Fix 4
Download most recent version of JDK and configure Netbeans to use that
Having strange problem for couple of days.
I have written 2 main files, so to test based on need.
I have been facing following strange problems,
The main fail stops executing after some statement. doesnt hang! after cleaning the build, and compiling again it got executing!
I updated few System.out.println statements, but i am cant see new statements.
I excluded the unwanted main files and tried. even commented the whole unwanted main files and tried.
I even tried changing the main file name that i am using.
I observe the eclipse is not compiling the main file i wanted or it is taking old class file some where residing?
I cant see the unwanted class anywhere in the workspace!!
anyone experienced similar problem?
Please try right-mouse click on the class in "Package Explorer", then
form the menu choose "Run As" -> "Java Application".
This will run (and compile if needed) the selected source code.
I copied a main file from other project, and that package got retained in that file. when i modify the code in copied main file, forgot to modify a constructor name which was pointing to earlier package. I missed to trace import statements and it was not expanded. when i try to copy the file to post in stackflow, i found earlier package was included and found that was the culprit!!
I am new to Java and started with Eclipse Kepler Service Release 1. I started a small project that contains two classes, each in its own file:
MIDI_Wrap_Test - a main (program) class
MIDI_Wrap - another class (MIDI_Wrap) which is intended as a MIDI wrapper. -
Both classes are in the same directory with file names being the same as the class name (with .java added of course). Something goes wrong and I want to debug it. However, when control transfers from the main program to the MIDI_Wrap file/class I get the error message 'source not found'.
I found out that this is a quite common error. The question and answer that seem to mirror my problem perfectly is found here. I added the project to the debug source path, noticing that the correct directories were already added but to no avail.
I must be doing something wrong but am not able to find out what. Can someone help me out of this?
I solved by shutting down eclipse and reopened it. This solved me, and code can be debug with source code view.
Error: Could not find or load main class jewelleryerpapplication.GUI.ERPMainMenu
Java Result: 1
Actually i am using Net Beans 7.1 and in that i am continuosly getting the same error but un able to get the solution for that even after installing the latest update for that. The solution which i got from some body that create new project and copy the source and library foldes in that Project from the previous which generate the above error. this solution works for me but i need some simpler solution for this problem.Lot of thanks in advance.
Don't Forget To Give UpVote It If It Helps.
Right click on project node, go to Set configuration, select the main class for your application. Then clean and build.
Even if this doesn't solve your problem, then delete the Netbeans cache by deleting the (index) folder
User\.netbeans\6.9\var\cache\index\
I think that the following is happening:
If this is a third party application, you have not included some jar files on your class path;
Or, (which in my opinion is the most likely) you do not have a method which has this signature: public static void main(String[] args). This method defines the main entry point for your application, not having it might cause that error when you try and run the project. To my knowledge, Netbeans creates a main class with such a method automatically whenever you create a new project. This might be the reason why you are not having this exception when you create a new Project and throw everything in it.
You might be having an issue with Netbeans itself. You can start by either checkin gout this previous SO thread in which a similar (I think) issue is being discussed, or else, as a final resort, you might want to remove Netbeans and all its files, and install an earlier version. You can also try and see if you get the same issue if you use a different IDE such as Eclipse.
the solution is,right click your package in netbeans,go to properties,source now go to the jre option and choose your version,the programme will now run.