Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio)
Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1798971] Wed, 28 November 2018 08:08 Go to next message
Peter Valencic is currently offline Peter ValencicFriend
Messages: 3
Registered: November 2018
Junior Member
Hi,
hello to all members, this is my first post on this "forum".

The problem I can't resolve is that I got the error: " cannot be resolved to a type".

Have tried with project "Clean" but it not works. Can someone give me some information on what else I can do to avoid this kind of messages?

For example, if I open the same project in NetBeans IDE, I don't get any warning or error (but prefer to use Eclipse).

If I try to build the project with mvn clean install, all works fine and I can "build" the project.

thank you for any info
regards
Peter
Re: Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1799007 is a reply to message #1798971] Wed, 28 November 2018 15:40 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Do you have the M2Eclipse plug-ins installed so that Eclipse can use what's in your
pom.xml file to find dependencies? Is the type that isn't found in one of those
dependencies, or a source file in your project?


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1799119 is a reply to message #1799007] Fri, 30 November 2018 03:56 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 141
Registered: March 2018
Senior Member
When I get this error message it's usually because I've left something off earlier in the file. For instance, I might use the WindowBuilder to make a JTextArea called txtrXcord, and then later add something to the java file that refer to txtrXcord before I come to the entry made by WindowBuilder. But the compiler doesn't know what txtrXcord is. So it cannot be "resolved," which means, "I can't figure out what one of these txtrXcord things I supposed to be. "

Declare txtrXcord as a JTextArea before it ever gets used, and remove the duplication below.

	public Drawer() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	//To fix the problem, put up here:
	/[color=green]/JTextArea txtrCurrentXCoordinate;[/color] // third thing I did, first thing I did to fix my mistake.
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
/*Second problem factor*/		[color=red]txtrCurrentXCoordinate.setText("Previous x coordinate");[/color] // second thing I did.
		//[color=red]RED FLAG[/color] error message : txtrCurrentXCoordinate cannot be resolved.
		
		
/*First problem factor*/[color=orangered]JTextArea[/color] txtrCurrentXCoordinate = new JTextArea(); //first thing I did
		/[color=green]/txtrCurrentXCoordinate = new JTextArea()[/color];//fourth thing I did and the second I did to fix my mistake.
		txtrCurrentXCoordinate.setText("Current x coordinate");
		txtrCurrentXCoordinate.setBounds(69, 175, 160, 36);
		frame.getContentPane().add(txtrCurrentXCoordinate);
	}
}


Another thing might be to use, e.g., some javex item without having included the appropriate javex,whatever above with the other "includes."
Re: Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1799145 is a reply to message #1799007] Fri, 30 November 2018 12:56 Go to previous messageGo to next message
Peter Valencic is currently offline Peter ValencicFriend
Messages: 3
Registered: November 2018
Junior Member
Quote:

Do you have the M2Eclipse plug-ins installed so that Eclipse can use what's in your
pom.xml file to find dependencies? Is the type that isn't found in one of those
dependencies, or a source file in your project?


No I don't have..

[Updated on: Fri, 30 November 2018 12:57]

Report message to a moderator

Re: Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1799146 is a reply to message #1799145] Fri, 30 November 2018 12:58 Go to previous messageGo to next message
Peter Valencic is currently offline Peter ValencicFriend
Messages: 3
Registered: November 2018
Junior Member
For example.. this is how it's look like:

https://i.postimg.cc/zX1Vp2FG/screenshot-274.jpg

something must be messed up with (Project ->Properties->Project Facets)

[Updated on: Fri, 30 November 2018 13:07]

Report message to a moderator

Re: Can't avoid "cannot be resolved to a type" (Eclipse/JbossStudio) [message #1799166 is a reply to message #1799146] Fri, 30 November 2018 20:23 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 141
Registered: March 2018
Senior Member
Start with a simple program.
Include a simplified version of the squib you've provided above. Use just the essentials. You will find that in that context there is nothing wrong with what you have written. You could then go ahead to add the other things that make your file more than a few lines long. If you do so a few lines at a time you should be able to isolate any problems. But I doubt that there will be any.
Here is my ultra simple java file as above but with the addition of the basics of your squib.

import java.awt.EventQueue;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;


import javax.swing.JFrame;
import javax.swing.JTextArea;

public class Drawer {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Drawer window = new Drawer();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Drawer() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */

	JTextArea txtrCurrentXCoordinate; 
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		txtrCurrentXCoordinate.setText("Previous x coordinate"); // second thing I did.


		txtrCurrentXCoordinate = new JTextArea();
		txtrCurrentXCoordinate.setText("Current x coordinate");
		txtrCurrentXCoordinate.setBounds(69, 175, 160, 36);
		frame.getContentPane().add(txtrCurrentXCoordinate);
	}// end initialize

	public class CommandData {
		private int cmdScheduleID;
		public int getCmdScheduleID() {
			return cmdScheduleID;
		}

	}
}


There are no red flags on the above code. Where do your red flags come from???

Now make a dummy class file for CommandData, let's call it CommanderData. It does nothing, and at this point it is not connected with your original program. It shouldn't cause any error messages. If it does, you'll have to ask somebody who knows much more than I do about how there could be a connection that vitiates CommanderData when the only connection Is that it is in the same subdirectory with some other xyz.java files.

Go back to the xyz.java file that calls CommandDataI(), comment that line out and replace it with one that calls CommanderData();
What happens?

I have no idea what it might be, but I think your trouble has to be at this point. There is probably nothing wrong with the code you posted above, so the problem must be somewhere else.

[Updated on: Fri, 30 November 2018 20:27]

Report message to a moderator

Previous Topic:HTTPS to HTTP cookie issue
Next Topic:Unable to Resolve Host Names for Any Repositories
Goto Forum:
  


Current Time: Thu Apr 25 01:50:22 GMT 2024

Powered by FUDForum. Page generated in 0.08128 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top