Im creating a message publishing application on eclipse for the minute there is no GUI involved it is just going to be running from the console. But when I compile and try to run the server class I get an error saying
The weird thing is the error on server.java line 24 is just a constructor creating a message class. I asked my tutor about this and he said it was some issue with the classpath not being defined properly in the IDE. I have tried compiling it and running it from command prompt and it works find it is just an Eclipse issue I believe. I have tried looking for an answer myself online but haven't come up with anything. If anyone has come across this before, how did you solve it?
Related
So recently I was bombarded with the below error.
I have a very bad understanding of Java and how the internal memory location and file compiling work. So, when I ran my program(every program gave me the error so I guess it doesn't matter which program I ran and for that matter, I didn't include it here), it started giving me this error. I looked if there were any errors with my classpath and working directory, but still, after applying those too it didn't help much, and I still got the same errors.
The programs ran from the terminal using commands but from the normal "Run" function, it gave me this error.
I just restored the default setting of the IDE and it now works.
The difference I found was that after restoring the default settings, the project location was the default folder- IdeaProjects- whereas when I encountered the error I used to set my own location for the projects. Is it due to this? I had the same kind of problem in eclipse when I set the location of the project outside of the eclipse workspace.
Is the location of the project simply the reason I got the below error and if so why? I just don't understand how the internal mechanism of the whole programming thing works. About the directory, memory allocation, etc. Can anyone provide some decent materials after which I can be at a stage where I can separate what is the error and why is it causing or why the program doesn't run?
Full error:
/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=57983:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/(myname)/Desktop/Folders/College/2nd sem/CS 2/Labs:projects/Lab3/Lab3dot34.0/out/production/Lab3dot34.0:/Users/(myname)/Desktop/Folders/College/2nd sem/CS 2/Labs:projects/Lab3/Lab3dot34.0 Main
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
Initially, I tried to view the working directories and add/change the classpath from the project structures like every suggestion found on the internet but still, the error existed.
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 in the past days i've decompiled minecraft 1.12.2 using mcp to make an "own" client. I ran it from eclipse and all was working just fine. But once i exported it, added the needed JSON file and started it from the minecraft launcher, it resulted the following error:
Exception in thread "Client thread" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.info(Ljava/lang/String;Ljava/lang/Object;)V
at net.minecraft.client.Minecraft.<init>(Minecraft.java:420)
at net.minecraft.client.main.Main.main(Main.java:115)
In my opinion that'a a bit strange, because when I ran it from eclipse that error did NOT occur.
I was thinking about adding the logger in the specific JSON file for the version but I do not know how to do it. I took the JSON file from a video where I expected my problem to be solved, made some changes, but it didn't. I also put the folder containing the logger-jar (org.apache....) in the client jar, but still no success.
Also i just decompiled 1.12.2 and recompiled it right away to see if i had messed up my code some how.
I hope someone can help.
This means at runtime you have a class that is different than what you had at compile time. You should try unzipping the jar and searching for the class file. It sounds like you need to potentially remove it and replace it with your own version.
Thanks to all who viewed an wanted to help!
Now I found an other way to use it. I wanted to export it to test
it on my server. But instead I used my account credentials to log in directly from eclipse.
:)
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.
Everything works fined, but suddenly eclipse stopped execute and junit tests or even main method, when i run them using run as - > Java application, run as -> junit test
It simply throws error
Caused by: java.lang.ClassNotFoundException: package.ClassName
whene ClassName - is class from where i trying to run method main.
It affect only one of my projects ... Different workspaces works fine, other project in same workspace works fine as well.
I'm sure if i recreate current project, error will gone. But the adjustments of this project in eclipse is really hard, so i want to avoid it.
Any clue?
The ClassName is not in the Class Path, if you start from console you should use -cp parameter , if from eclipse, please add ClassName to the sources of current(start) project.
Thanks to adarshr, I was able to look at the Problems window and determine that the build was failing because it could not find a class I had written.
I had used the MS TFS plugin to create a "shelveset" and it was supposed to have removed my pending changes in the process. However, this integration with the TFS snapin and Eclipse is obviously not well implemented, since the Eclipse project still thought the file existed and was complaining that it could not be compiled.
I went and manually deleted those "files" or "non-existing files" from the Eclipse project (that I thought I had removed with the shelveset action) and the problem was solved.
Also....
Another annoying things is that the Tomcat error I was getting by trying to debug within Eclipse was like this:
SEVERE: Error configuring application listener of class
com.CompanyName.ProjectName.servlet.StartupConfigListener
java.lang.ClassNotFoundException:
com.CompanyName.ProjectName.servlet.StartupConfigListener at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
In reality, there was no problem at all with StartupConfigListener.java!! The build failed due to the OTHER problems I mentioned above, and therefore I guess this was the first class it attempted to load and failed.... because the entire project hadn't been able to compile perhaps?
(Here's to hoping my next project is using Visual Studio instead of Eclipse!)
Ok, I finally figured it out. The problem was with installed JRE in eclipse setting. I was playing around with this setting and changed installed JRE to JDK, and for some reason it broke the eclipse project.
You can also try going back to the basics. Check your command line and VM args. I've had this situation where a VM arg I was passing in was a path to a file that had a space in the path, and I had forgotten to include the full path in quotes. So e.g., if my arg looked something like
-DFILE=C:\Documents and Settings\myfile
...I'd get a java.lang.NoClassDefFoundError caused by a java.lang.ClassNotFoundException.