954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

cannot resolved to a type error

Hi,
I created a class named Test.java

public class Test {
	public Test() {
		System.out.println("Testing......");
	}
}

It sucessfully compiles.
Then i create another java classMenu.java and here i trying to create an object of the Test class.

class Menu {
	
	public static void main(String[] args) {
	
		Test arrList = new Test();
		
	}
}

I got an error "Test cannot resolved to a type error " while i compile the Menu.java
I am new to java
Anyone can help ?
Thanks in advance.

pssubash
Light Poster
31 posts since Feb 2008
Reputation Points: 10
Solved Threads: 4
 

You need to have both the class files in a same folder. The error means I couldn't resolve(find) the Type Test Class.

vijayr2m
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 1
 

Yes,it aleady resides the same folder.but the iuuse will come.
Please find the attached files

Attachments Test.java (0.08KB) Menu.java (0.12KB)
pssubash
Light Poster
31 posts since Feb 2008
Reputation Points: 10
Solved Threads: 4
 

Do you have both the .class files and the java files in the same folder?
Test.java, Test.class, Menu.java, Menu.class ? I checked the code and it is correct.

The difference is that I have declared a package. The code should work without one. But is is better to use one. The right way would be to declare a package and set to the classpath the location of that package.

Can you verify at least that all of the above files mentioned are in the same folder?

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

Menu.class is not there,rest is there.
I got the above specified error while i am trying to compile Menu.java.
OS using : Linux

pssubash
Light Poster
31 posts since Feb 2008
Reputation Points: 10
Solved Threads: 4
 

No one have any idea about it ?
Hope this is a small error ?
Can any one help me ?

pssubash
Light Poster
31 posts since Feb 2008
Reputation Points: 10
Solved Threads: 4
 

Have you tried to declare a package at those classes?
Don't forget to set the classpath as well. There are instructions you can follow. Look at the tutorials at the top of the java forum

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: