• Post Reply Bookmark Topic Watch Topic
  • New Topic

When I run my code it says no main class found?  RSS feed

 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when I try and run this code I get a message that says no main class found. Why would this be when my main class is clearly there?
 
Sergiu Dobozi
Ranch Hand
Posts: 107
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are repeating the mistake you did in the Scrabble, class Date is an inner class and your main method is stuck in that inner class. I would suggest removing the top class first of all.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main method needs to be static.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, the values you seem to think are dates on lines 33 and 34 are not dates. They are simple integer values that you are dividing and the result is 0 in both cases.
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:The main method needs to be static.


Making the main method static makes gives me this error though:
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lexi Turgeon wrote:
Junilu Lacar wrote:The main method needs to be static.


Making the main method static makes gives me this error though:


Nevermind, I found my error.
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more problem... I have the program working how it should. But it prints these 0's. Here is my output:


And in my code I know I tell it to print the 0's. My question is, is there anything I can put there instead of the zeros so that it will not print the 0's?

 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know which lines are printing those 0s, then all you have to do is delete them. They don't make sense anyway.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing that's frustrating to watch as you struggle through all these exercises is the fact that you don't format your code properly. You are using NetBeans, which has a keyboard shortcut to do that for you automatically and yet for some reason, you don't use it consistently. Ctrl+Shift+F

Properly formatted and aligned code gives you a sense of the structure and organization of your code. Without it, you and whoever reads your poorly formatted code will likely get confused, or worse, misled, about how your code works.
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:One thing that's frustrating to watch as you struggle through all these exercises is the fact that you don't format your code properly. You are using NetBeans, which has a keyboard shortcut to do that for you automatically and yet for some reason, you don't use it consistently. Ctrl+Shift+F

Properly formatted and aligned code gives you a sense of the structure and organization of your code. Without it, you and whoever reads your poorly formatted code will likely get confused, or worse, misled, about how your code works.

I format it all the time, It is just how it comes up when I enter it in on my forums.
NetBeans does not let me just delete the 0's, it says the statement becomes incorrect when I do that.
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My uncle just solved my problem, never mind.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and what was the solution?
 
Lexi Turgeon
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solution:



 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your Date class, why do you need lines 6 and 7?

In MoreDates2, line 15, println() does not need any argument if all you want to do is print a blank line.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!