• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Main method not found

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings Code Ranchers, I hope you're having a great Friday evening.

Today I watched a 2 hour video series on Java and after completion I tried I whip up a quick code to test what I've learned and have run into a little road block. One of the issues with doing this on your own, and not having an in person instructor is when things like this arise. However, I am really thankful for the Code Rancher community and all the previous help I've received! You all are really great.

Would greatly appreciate your help with the following, if anyone would be so kind to spare a few moments of your time and expertise.



This is the error message I am receiving:


run:
Error: Main method not found in class keyboard.Keyboard, please define the main method as:
  public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
C:\Users\epoch\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)



I have "public static void main(String[] args) {" on line 43... so am I a little confused on what the issue is? Also the IDE feedback doesn't help... this is what happens if I follow the IDE's recommendations:



With a result of:


run:
Aldos's typing test Words Per Minute (WPM) results are: 0
Syntari's typing test Words Per Minute (WPM) results are: 0
BUILD SUCCESSFUL (total time: 0 seconds)



Not what I am looking for... :\

Lastly... would anyone be able to give me a book recommendation? My goal is to really step up my Java skills between now and March. I saw a post for a Java All-in-One (for Dummies) book in one of the threads on here. Is that the go to one? Or would someone else be able to recommend another good one, around my skill level, which I am sure you can identify with me making posts like this.

Thank you!!!

AK
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for all the <b>'s ... Not sure why it is doing that :\
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code without all the <b>'s:

public class Keyboard{
  private int typeRate = 0; // Words per minute typed on the keyboard by user: Aldos
  private int errorRate = 0; //

  public Keyboard() {
     typeRate = 78; // Result of taking a typing test at www.typingtest.com/ - 393 char/78 WPM
     errorRate = 0; // 100% accuracy, no mistyped words.
  } // End of Constructor

  public void setTypeRate (int rate) {
   typeRate = rate;
  } // End of method #1

  public int getTypeRate () {
   return typeRate;
  } // End of method #2

  public void setErrorRate(int errors) {
   errorRate = errors;
  } // End of method #3

  public int getErrorRate() {
   return errorRate;
  } // End of method #4

  public int calculateRate() {
   int results = typeRate - errorRate;
   return results;
  } // End of method #5
} // End of Class

  public static void main(String[] args) {
   Keyboard_Typer Syntari = new Keyboard_Typer();
   Keyboard_Typer Aldos = new Keyboard_Typer();
   int results = 0;

   Aldos.setTypeRate(78); // Set Aldos's WPM
   Aldos.setErrorRate(0); // Set Aldos's error rate
   results = Aldos.calculateRate();
   System.out.println("Aldos's typing test Words Per Minute (WPM) results are: " + results);

   Syntari.setTypeRate(45); // Set Syntari's WPM
   Syntari.setErrorRate(9); // Set Syntari's error rate
   results = Syntari.calculateRate();
   System.out.println("Syntari's typing test Words Per Minute (WPM) results are: " + results);
   } // End of method #7
} // End of class
 
Saloon Keeper
Posts: 6199
58
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have two closing braces commented as end-of-class and main() is not inside your class.
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//

package keyboard;

/**
*
* @author epoch
*/
public class Keyboard{
  private int typeRate = 0; // Words per minute typed on the keyboard by user: Aldos
  private int errorRate = 0; //

  public Keyboard() {
     typeRate = 78; // Result of taking a typing test at www.typingtest.com/ - 393 char/78 WPM
     errorRate = 0; // 100% accuracy, no mistyped words.
  } // End of Constructor

  public void setTypeRate (int rate) {
   typeRate = rate;
  } // End of method #1

  public int getTypeRate () {
   return typeRate;
  } // End of method #2

  public void setErrorRate(int errors) {
   errorRate = errors;
  } // End of method #3

  public int getErrorRate() {
   return errorRate;
  } // End of method #4

  public int calculateRate() {
   int results = typeRate - errorRate;
   return results;
  } // End of method #5
 
public static void main(String[] args) {
   
   Keyboard_Typer Syntari = new Keyboard_Typer();
   Keyboard_Typer Aldos = new Keyboard_Typer();
   int results = 0;

   Aldos.setTypeRate(78); // Set Aldos's WPM
   Aldos.setErrorRate(0); // Set Aldos's error rate
   results = Aldos.calculateRate();
   System.out.println("Aldos's typing test Words Per Minute (WPM) results are: " + results);

   Syntari.setTypeRate(45); // Set Syntari's WPM
   Syntari.setErrorRate(9); // Set Syntari's error rate
   results = Syntari.calculateRate();
   System.out.println("Syntari's typing test Words Per Minute (WPM) results are: " + results);
   } // End of method #7


   }
}
} // End of Class



Starting to get one the right track?

With the above code, receiving the follow errors:


run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
 symbol:   class Keyboard_Typer
 location: class keyboard.Keyboard
at keyboard.Keyboard.main(Keyboard.java:41)
C:\Users\epoch\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)

 
Sheriff
Posts: 6259
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Keyboard_Typer in the same package as Keyboard?  If not, add an import to the class Keyboard_Typer.

If the two classes are in the same package, make sure they were both compile with the same level of JavaFX.
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning Knute Snortum,

About to head out the door for a quick workout before breakfast. Wanted to reply to you first.

I've made the following change (and I hope the <b>'s don't return...):



Results:


run:
Aldos's typing test Words Per Minute (WPM) results are: 0
Syntari's typing test Words Per Minute (WPM) results are: 0
BUILD SUCCESSFUL (total time: 1 second)



I've got a successful compile! That's a start. But why am I getting 0's instead of the 78, 0 and 45, 9 that I input?

AK

(PS- I'll repost in just text format if another wave of <b>'s comes through.)
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea why that's happening? I am directly copying/pasting from NetBeans IDE 8.2 when the wave of <b>'s comes, using the bracket code format. How visually unappealing...

Clean version:



//

package keyboard;

/**
*
* @author epoch
*/

public class Keyboard{
  private int typeRate = 0; // Words per minute typed on the keyboard by user: Aldos
  private int errorRate = 0; //

  public Keyboard() {
     typeRate = 78; // Result of taking a typing test at www.typingtest.com/ - 393 char/78 WPM
     errorRate = 0; // 100% accuracy, no mistyped words.
  } // End of Constructor

  public void setTypeRate (int rate) {
   typeRate = rate;
  } // End of method #1

  public int getTypeRate () {
   return typeRate;
  } // End of method #2

  public void setErrorRate(int errors) {
   errorRate = errors;
  } // End of method #3

  public int getErrorRate() {
   return errorRate;
  } // End of method #4

  public int calculateRate() {
   int results = typeRate - errorRate;
   return results;
  } // End of method #5
 
  static class Keyboard_Typer {

       private int calculateRate() {
           return 0;
       }

       private void setErrorRate(int i) {
       }

       private void setTypeRate(int i) {
       }
}

 
public static void main(String[] args) {
   
   Keyboard_Typer Syntari = new Keyboard_Typer();
   Keyboard_Typer Aldos = new Keyboard_Typer();
   int results = 0;

   Aldos.setTypeRate(78); // Set Aldos's WPM
   Aldos.setErrorRate(0); // Set Aldos's error rate
   results = Aldos.calculateRate();
   System.out.println("Aldos's typing test Words Per Minute (WPM) results are: " + results);

   Syntari.setTypeRate(45); // Set Syntari's WPM
   Syntari.setErrorRate(9); // Set Syntari's error rate
   results = Syntari.calculateRate();
   System.out.println("Syntari's typing test Words Per Minute (WPM) results are: " + results);
   } // End of method #7


   }
}
} // End of Class
 
Knute Snortum
Sheriff
Posts: 6259
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The b's aren't anything you're doing.  It's a problem we're working on.  Thanks for your patience!
 
Knute Snortum
Sheriff
Posts: 6259
167
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why you have the class Keyboard_Typer.  What do you think it's doing?  Try using Keyboard instead.
 
Aldos Kraut
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! That solved it. Really appreciate everyone's help.


run:
Aldos's typing test Words Per Minute (WPM) results are: 78
Syntari's typing test Words Per Minute (WPM) results are: 36
BUILD SUCCESSFUL (total time: 2 seconds)

 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!