Questions tagged [main-method]

115 questions
-1
votes
7 answers

no method main - but main is there?

class TapeDeck { boolean canRecord = false; void playTape() { System.out.println("Tape Player"); } void recordTape() { System.out.println("Tape Recording"); } } class…
-1
votes
1 answer

Exported runnable Java program does not work with main method

I created a small game from my Java book of exercises, when I compile it in Eclipse it runs fine, but once I add the main method and export it as a .jar onto my desktop it does not work when I double click it, neither does it work on the command…
Pav
  • 57
  • 7
-1
votes
2 answers

How to test my program from the main method JAVA

I am new to Java. I would like to test the methods available in the Calculator. What could be the most efficient way you could test this? package BeginnerLevel; import java.util.Scanner; public class Calculator { This is the…
Klayd Pro
  • 1
  • 1
  • 2
  • 7
-1
votes
2 answers

How to use main method in method overriding?

I have just started learning Java and I am learning method overriding. I am getting an error in a program while trying to run it in eclipse. The program is as follows: class Vehicle{ void run(){System.out.println("Vehicle is running");} } …
Rahul
  • 9
  • 4
-1
votes
1 answer

Calling a static method on an abstract class outside the main method

This program works with no problems public class Test{ static int DAY_IM = 1000*60*60*24; public static void main(String[] args) { Calendar c = Calendar.getInstance(); c.set(2004,0,7,15,40); long day1 = c.getTimeInMillis(); for…
covans
  • 41
  • 9
-1
votes
1 answer

Server/Client Running with command line

I have a question regarding server/client running on the command line. The server should be run something like this Server should run with a command line passing port number java Server port_number Client should run with command line as following…
-1
votes
1 answer

How to access variable in main method from actionlistener

I have three classes that are concerning me at this point: a Car class, CarGUI class, and actionlistener. I want to create a new instance of a Car class and have it referenced in the actionlistener. When I declare it outside of the main method,…
R Mason
  • 1
  • 2
-1
votes
2 answers

Why are (String[] args) not used as main method arguments in BlueJ?

I've been using the Java IDE - BlueJ but I can't understand why the main method cannot be defined as public static void main(String[] args) in it. I get a syntax error when I try it.
Srirag vu
  • 62
  • 1
  • 6
-1
votes
3 answers

How to return string with error "void method cannot return a value"?

I turned a codingbat warmup exercise into a program on Eclipse. The exercise calls to take the last char of a word and tack it onto both the front and end of a word, e.g. "cat" → "tcatt." First attempt: I started with this set of code and received…
user9503053
  • 77
  • 1
  • 11
-1
votes
1 answer

Error: Main method not found in class... why am I getting this?

Before people start flagging this question as a duplicate, know that I took the time too look at similar questions, and found that the answers to other "Error: Main method not found in class..." were not clearly applicable to my situation (according…
Patrick
  • 67
  • 7
-2
votes
1 answer

Difference of args vs arg in main-method, java?

Why does " public static void main(String[] arg) { " work instead of "public static void main(String[] args) { " ? Does it have anything to do with the String-Array? And how exactly does it work? May using "arg" instead of "args" just be a tiny bit…
-2
votes
1 answer

Why can't I initialize variables in methods?

I literally just want this java program to return 2. Why can't I type wait(); in main to do this? I have an unrelated constructor (to this task of returning 2), and I've tried making an object in main to make it work but that didn't help. Would a…
-2
votes
1 answer

I want to use main variable(Scanner) in another method

import java.awt.*; import java.awt.event.*; import java.util.Scanner; class Graph_mod extends Frame { public static void main( String[] args ) { Scanner input = new Scanner(System.in); System.out.println("enter v :"); double v =…
이석준
  • 3
  • 2
-2
votes
3 answers

Main class is not being found when I run my project on eclipse neon

I am trying to run my project, but the main class isn't being found. Whats wrong? Here's my code. public class ArrayPrinter { public static void printArray(int[] arr) { int size = arr.length; System.out.print("["); for(int i=0;i< size;…
-2
votes
1 answer

Having trouble with an error Error: Main method not found in class GUITest

Im having a problem with my GuiTest class. Here is the error,"Error: Main method not found in class GUITest, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend…
Imani M. Jackson
  • 201
  • 1
  • 2
  • 9