d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Server Socket Dilemma > Builds Just Fine In Ide
Add Reply New Topic New Poll
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Feb 4 2018 11:39am
So I am writing code to make a server store information but the only interaction is through a client.
I'm trying to deploy the server remotely and get the following error:

Exception in thread "main" java.lang.NoClassDefFound
http://www.codegravity.com/blog/exception-in-thread-main-java-lang-noclassdeffounderror

Googled problem is that, still can't fix, is it bcause i have a similiar file in a different directory with the same name?

Advice please!
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Feb 4 2018 12:11pm
Iirc just deleting at all .class files and recompiling. Some weird issue with the Java compiler not making the .class file after some changes.
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Feb 4 2018 01:33pm
Quote (Mastersam93 @ Feb 4 2018 11:11am)
Iirc just deleting at all .class files and recompiling. Some weird issue with the Java compiler not making the .class file after some changes.


I just scp the files into the location and it worked with a previous one just not this one, will this still fix it? (Giving it a shot, I'll lyk)
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Feb 4 2018 01:36pm
What is happening is that you're running something with Java. Whatever you're running has a dependency on a class which it cannot locate. The class it cannot locate will be in the full stack trace. If you provide the full stack trace, the command you're running, and the file structure we may be able to help.

Quote (Cocoo @ Feb 4 2018 12:39pm)
is it bcause i have a similiar file in a different directory with the same name?


It could be and you should avoid doing anything like this.

This post was edited by waraholic on Feb 4 2018 01:36pm
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Feb 4 2018 01:40pm
Quote (waraholic @ Feb 4 2018 12:36pm)
What is happening is that you're running something with Java. Whatever you're running has a dependency on a class which it cannot locate. The class it cannot locate will be in the full stack trace. If you provide the full stack trace, the command you're running, and the file structure we may be able to help.



It could be and you should avoid doing anything like this.


Sorry Java isn't my native language, I'm more of a C# / C++ kinda guy and I've never really run into this. My professor told me this: C++/C# is the abusive drunk stepfather that doesn't care what you do, you want to point at numerous things and not initialize variables? You're golden! Java not so much, it wants to swaddle you and tell you no.
I thought java file names were named after the class, I just modified the code and then scp'd it into a new directory to try to run, using unix btw intelij for ide.
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Feb 4 2018 01:51pm
Well the good thing is that Java runs the same on every OS (with some minor differences if you're accessing files or native commands ofc).

Yes the Java file should contain a class with the same name. It isn't a good idea to have multiple files with the same name and package. If that is the case and both files are found by the classloader it will only load one of them (unless you implement your own classloader which is a bad idea in this case).
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Feb 8 2018 07:30am
Incase anyone was wondering, I compiled each program at a time when there is a javac *.java command :O thank you for your help!

This fixed my problem.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll