r/javahelp • • May 12 '19

I can't execute java code after compiling

Hi there
Is there anyone that have come across this error:
Error:Could not find or load main class
Caused by: java.lang.ClassNotFoundException
I deleted and added the classpath reinstalled java but nothing has helped
The code compiles but it doesn't run

0 Upvotes

22 comments sorted by

View all comments

1

u/philipwhiuk Employed Java Developer May 12 '19

How are you trying to run it?

1

u/TalxTrapi May 12 '19

In terminal Javac (name of class).java And Java (name of class)

1

u/philipwhiuk Employed Java Developer May 12 '19

Is your class in a package.

1

u/TalxTrapi May 12 '19

Nope

2

u/morhp Professional Developer May 12 '19

Show us your code. And maybe a screenshot of your file manager so we can see the files.

1

u/TalxTrapi May 12 '19

A screenshot with code and the terminal http://prntscr.com/nnmgvf
I don't think that the problem is in the code

1

u/morhp Professional Developer May 12 '19

That looks fine. Make sure the Test.java in Notepad is saved and you opened the right file in the right Desktop folder. Must be a dumb mistake like that.