I am having a problem importing classes and setting variables and I need help with a test program I am doing. So I am testing out a program that just simply outputs what your input was and puts a time stamp ( Like Skype ). I am having an issue getting the message and time variable type to work! Here is my code:
class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Message messageObject = new Message ();
Time timeObject = new Time ();
System.out.println("Enter your message here: ");
String message = input.nextLine();
messageObject.simpleMessage(message);
timeObject.getTime();
}
void simpleMessage(String message) {
System.out.println(message + time);
}
}
And here is my error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Message cannot be resolved to a type
Message cannot be resolved to a type
The constructor Time() is undefined
at Test.main(Test.java:8)
For this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
There are problems with your import or package name.
You can delete the package name or fix import errors
Check Following : 1) Package names 2) Import Statements (import every required packages) 3) Proper set of braces ,i.e { } 4) Check Syntax too.. i.e semicolons,commas,etc.
You have to Import the Scanner and Timer Package Properly using the java.util classes.
import java.util.Scanner;
import java.util.Timer;
Two possibilities here. Java Version incompatible or import
Source: Stackoverflow.com