• Register
0 votes

Problem :

I am having a trouble while importing classes and setting variables and also I need help with my test program which I am doing. I want to test a program that simply outputs what the input was and puts the time stamp ( like Skype does ). I am having the trouble in getting a message and time variable type to work! Below is my code:

class MyTest {
    public static void main(String[] args) {

        Scanner myinput = new Scanner(System.in);
        Message mymessageObject = new Message ();
        Time mytimeObject = new Time ();

        System.out.println("Please enter your message here: ");
        String mymessage = myinput.nextLine();


    void mysimpleMessage(String mymessage) {
        System.out.println(mymessage + mytime);

And below 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 MyTest.main(Test.java:8)


7 5 2
3,870 points

2 Answers

0 votes

Solution :

Your problem is in following line: Message mymessageObject = new Message ();
Above error says that your Message class is not known to compiler at compile time.

So you need to simply import a Message class.

Something like below code:

import package1.package2.Message;

You can simply refer the below link for further information.


9 7 4
38,600 points
0 votes


Your difficulty is in this line: Message messageObject = new Message ();
This error indicates that the Message class is not familiar at compile time.

So you require to import the Message class.

Something like this:

import package1.package2.Message;

I had a pair of various Java versions installed on my system. Hence foremost I uninstalled them all. Then I reinstalled the one i wanted to employ (which in my case is 8.0_151).


  1. Go to Preferences >> Java >> Installed JRE's

  2. Click on  add and browse to \Program Files\Java\jdk1.8.0_151

    In my example the "Location" variable for the jre did not alter however the "Name" variable for the jre in this dialog box did.  I am not certain the influence of this however it is the only matter that seems to have altered.  Who knows, maybe "refreshing" this variable is the key.
  3. Click OK and then place the newly included jre as the default.  

  4. Click OK, tell a small prayer and run a job.

Hopefully, You are able to solve this problem.
10 6 4
31,120 points

Related questions

0 votes
1 answer 97 views
Problem : I am having a problem importing classes and setting variables and I need help with it. I am getting below error exception in thread "main" java.lang.error: unresolved compilation problem:
asked Oct 22, 2019 peterlaw 6.9k points
1 vote
1 answer 38 views
Problem: I am a begginer in java programming language and I have been coding for just some days. To practice my programming I wrote this code in java: public class Main { public static void main(String[] argv){ int 2count, h-l, a/b, } } But It shows me the error message ... , . expected Syntax error on token ",", ;expected at Main.main(Main.java:3) Whats is wrong in my code can anyone help me out?
asked Apr 6 LizzyM 6.1k points
1 vote
1 answer 24 views
Problem: I got error while applying weblogic patch useing bsu.sh: patch_download_dir=$FMW_HOME/utils/bsu/cache_dir -patchlist=GFWX -prod_dir=$FMW_HOME/wlserver_10.3 -log=$FMW_HOME/utils/bsu/bsu_weblogic.log Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded ... .bea.plateng.patch.Patch.main(Patch.java:281) Can anyone explain me this and help me to solve this error?
asked Mar 27 LizzyM 6.1k points
0 votes
1 answer 19 views
1 vote
1 answer 16 views
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. “Exception in thread "main" java.lang.arrayindexoutofboundsexception:” I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
asked Mar 30 morrisBson 3.2k points