0

many codes are not compatible with eclipse, why?

I write down every code listed in the example or in the "try it yourself" mode in eclipse to better understand it. but every time I do that there's always some error which doesn't execute the output even if I copy/paste the code, would appreciate any suggestions.

2nd Apr 2017, 4:28 AM
Jigmey Lodue
Jigmey Lodue - avatar
3 ответов
+ 1
weird because it works for me. what does the error say?
2nd Apr 2017, 4:48 AM
Edward
0
The method main cannot be declared static; static methods can only be declared in a static or top level type Exception in thread "main" java.lang.Error: Unresolved compilation problem: at project1.Myclass.main(Myclass.java:19)
2nd Apr 2017, 5:29 AM
Jigmey Lodue
Jigmey Lodue - avatar
0
I found a way around this issue. for your code to work on eclipse or other ides, make sure that the class which contains the main method is set as public, while other classes, is just set as just class. Use the method while working in one page. use this syntax public class egg{ public static void main(String args[]){ } } class subegg{ //method } class spice { //method } class boil{ //method } Another method to solve this issue is to create another class, in the same package, this class will contain only the main method. Try and run and give your feedback!!
18th Apr 2017, 6:43 AM
Ojini Chizoba Jude
Ojini Chizoba Jude - avatar