[java] Exception in thread "main" java.lang.Error: Unresolved compilation problems

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)

This question is related to java testing time import message

The answer is


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


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to testing

Test process.env with Jest How to configure "Shorten command line" method for whole project in IntelliJ Jest spyOn function called Simulate a button click in Jest Mockito - NullpointerException when stubbing Method toBe(true) vs toBeTruthy() vs toBeTrue() How-to turn off all SSL checks for postman for a specific site What is the difference between smoke testing and sanity testing? ReferenceError: describe is not defined NodeJs How to properly assert that an exception gets raised in pytest?

Examples related to time

Date to milliseconds and back to date in Swift How to manage Angular2 "expression has changed after it was checked" exception when a component property depends on current datetime how to sort pandas dataframe from one column Convert time.Time to string How to get current time in python and break up into year, month, day, hour, minute? Xcode swift am/pm time to 24 hour format How to add/subtract time (hours, minutes, etc.) from a Pandas DataFrame.Index whos objects are of type datetime.time? What does this format means T00:00:00.000Z? How can I parse / create a date time stamp formatted with fractional seconds UTC timezone (ISO 8601, RFC 3339) in Swift? Extract time from moment js object

Examples related to import

Import functions from another js file. Javascript The difference between "require(x)" and "import x" pytest cannot import module while python can How to import an Excel file into SQL Server? When should I use curly braces for ES6 import? How to import a JSON file in ECMAScript 6? Python: Importing urllib.quote importing external ".txt" file in python beyond top level package error in relative import Reading tab-delimited file with Pandas - works on Windows, but not on Mac

Examples related to message

Exception in thread "main" java.lang.Error: Unresolved compilation problems How do I raise the same Exception with a custom message in Python? Get all messages from Whatsapp How to send email to multiple recipients using python smtplib? Git commit with no commit message Problems with entering Git commit message with Vim jQuery show for 5 seconds then hide How to show the "Are you sure you want to navigate away from this page?" when changes committed?