aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Frustrating eclipse - cannot be resolved to a type ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Frustrating eclipse - cannot be resolved to a type ?" Watch "Frustrating eclipse - cannot be resolved to a type ?" New topic
Author

Frustrating eclipse - cannot be resolved to a type ?

Arnold Strong
Ranch Hand

Joined: Jun 24, 2012
Posts: 40
I don't really know what I am doing. I am just picking up random tutorials from the net and doing a Java project.
I made a "lib" folder in my eclipse project. Added the necessary JARs to build path.
When I try to make a simple "hello world" type of example, I get the same error "cannot be resolved to a type" at many places.
Looks like i have to import the JAR files by putting import statements, right ?
If yes, then how do i import the JAR files ?

Please help me.


Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

Option 1 -
Right click on project in Navigator or Project Explorer > Properties > Java Build Path > Libraries > Add jars > Add all jars in your lib folder

Option 2 -
Right click on project in Navigator or Project Explorer > Properties > Java Build Path > Libraries > Add external jars > Add jars from your hard disk

Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

What type of "project" did you start.

When you select "new project", Eclipse does most of the setup for you.

You then need to add dependent jars to your Java Build Path in the project properties.
Eclipse adjusts the .classpath file automatically.

I sense you are trying to do too much too quickly, even your comment about "random" examples.

Start small, there are in fact a ton of examples in the posts here. I simply copy them to a workspace and help!

WP
Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

Actually Willliam is right, you would not need any external jars for a hello World.
Simply create a java project and eclipse will add jre or jdk to your classpath and buildpath.
Arnold Strong
Ranch Hand

Joined: Jun 24, 2012
Posts: 40
William P O'Sullivan wrote:What type of "project" did you start.

When you select "new project", Eclipse does most of the setup for you.

You then need to add dependent jars to your Java Build Path in the project properties.
Eclipse adjusts the .classpath file automatically.

I sense you are trying to do too much too quickly, even your comment about "random" examples.

Start small, there are in fact a ton of examples in the posts here. I simply copy them to a workspace and help!

WP


I am not really a beginner anymore.
This is a "hello world" for google analytics using Java API.
The code below is from the google website.


Also see snapshot of project file structure. Dont know why all those folders are there.



[Thumbnail for ana.JPG]

Aniruddh Joshi
Ranch Hand

Joined: Jul 29, 2008
Posts: 275

Arnold Strong wrote:I am not really a beginner anymore.
This is a "hello world" for google analytics using Java API.
The code below is from the google website.



Thanks for the details, now I understand you're trying to quickly learn writing for google analytics but are not very accustomed with eclipse.
Here is what I think is wrong with your project -
- You need not copy all referenced libraries into lib.
- A valid JDK or JRE is not on your classpath - Since class Arrays is not identified.
Check if its a google's version of Arrays. Posting your import statements on top of the file will help.
They should be marked in red by eclipse too. When you work with java in eclipse( or any IDE for that matter ) first see if anything ir red in your import statements.
- Google jars are NOT on your classpath. Simplest way is to open the .classpath file. - Since classes like HttpTransport and Credentials are not identified.

Try the below-
GO to any red marked line > Press Ctrl + 1 > Fix project setup. See what happens and let us know.
Cheers!
Arnold Strong
Ranch Hand

Joined: Jun 24, 2012
Posts: 40
Thank you so much for helping me

Aniruddh Joshi wrote:
- You need not copy all referenced libraries into lib.


What is this lib folder really for ? Can't I just import all the Jars into the project instead ? If I do that, they appear in "referenced libraries" section when i expand the project folder.

Aniruddh Joshi wrote:
- A valid JDK or JRE is not on your classpath - Since class Arrays is not identified.
Check if its a google's version of Arrays. Posting your import statements on top of the file will help.
They should be marked in red by eclipse too. When you work with java in eclipse( or any IDE for that matter ) first see if anything ir red in your import statements


That error is due to AnalyticsScopes and not Arrays.

Aniruddh Joshi wrote:
- Google jars are NOT on your classpath. Simplest way is to open the .classpath file. - Since classes like HttpTransport and Credentials are not identified.


Do i have to open the classpath by going to the project folder each time or can i do it withing eclipse itself ?
How do i add stuff to the classpath. I had tried doing it manually once, but dont' know if it worked.

More importantly, how do i learn eclipse ? I prefer books that go from zero to advanced concepts. But there are none, except the one by lars vogel and that is too elementary.

Once again, thanks.
Arnold Strong
Ranch Hand

Joined: Jun 24, 2012
Posts: 40
Giving up on the useless google API. I am doing Spring !
See you guys !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frustrating eclipse - cannot be resolved to a type ?