0
Could not find or load class
I can do it. When I enter the code: public class Animal { void bark() { System.out.println("Woof-Woof");} } class MyClass { public static void main(String[ ] args) { Animal dog = new Animal(); dog.bark(); } } Eclipse tell me: "Error: Could not find or load main class src.HelloWorld.Helloclass" Program (Eclipse) write in errors: "type of MyClass already defined" Help me, please, gyus!
5 Answers
+ 1
Thanks for everybody!
I am stupid idiot. I had to create a code for MyClass in window for it class. But I did not it. When I corrected my mistake, the program started to work.
(Sorry for my English, if anything - I'm russian)
0
MyClass should be a public class in its own file. Because it's not public, Eclipse can't see it for execution
0
Thanks for answer. But MyClass is "public class"
0
working for me!
https://code.sololearn.com/czFrVlPSD431/?ref=app
- 2
MyClass has no access modifier, therefore it is not public. I've just tried your code in eclipse and I can't even run an application, because main can't be seen I think.
Where/what does HelloWorld.HelloClass look like? You might be trying to run in the wrong location.
Also do you have another 'MyClass' in the same package/project?
edit: correction, after playing around in run configurations I was able to get it to run, maybe check that