Steps to resolve the imports in eclipse? - java

Firstly, I have seen several question related to this issue but it seems like those questions might be some steps ahead of my understanding.
I am fairly new to java and consider myself as a self learning beginner. Mostly I face this problem where I do an import. I need it because that import is linked with the use of some really nice and powerful function(s), but always fail if import does not work and end up not using that.
The message is, e.g. "The import com.google can not be resolved".
I have been using eclipse in Ubuntu.
After trying some of the given solutions without being able to view them in the proper context, I already have messed up my eclipse environment and the trouble is still there.
Can anybody kindly show me the complete steps of doing these imports successfully in eclipse for java?

For using 3rd party jars you need to add the jars in the build path.
Follow the following step
right click project
click build path
click libraries tab
then add external jar
Now give the path of the jar location

Related

Want to contribute to OkHttp, but unable to import the code into IntelliJ using Maven

After forking OkHttp and then cloning it, I tried to import the project into IntelliJ using Maven.
However, IntelliJ is not resolving the dependencies properly for me. I see errors all over and I have to add the dependencies between each module and external libraries myself.
There must be a proper way to do this, really appreciate any help I can get here.
Edit:
I am putting the screenshots here to explain better
This is one of those dependencies errors I am facing
From this you can see that no dependencies is added automatically
I imported the project from the root folder pom file
If it helps, this is the project I am trying to import OkHttp. I am expecting a much easier way to get the code down and to start work on them.
Sorry for late answer, but maybe it helps someone especially I keep seeing similar problems all the time and had them myself few times. These steps usually works for me and were tested on OkHttp. They are the same like from my comment above but maybe something has been missed:
git clone https://github.com/square/okhttp.git
Download JDK (in my case it's 1.8.0_91 but it shouldn't be so important)
Download Apache Maven (3.3.9 works for me)
Run IntelliJ Idea (tested on 2016.2 Community) and enter "Settings" (Click "Cancel" if a project is loaded automatically)
Find "Maven" and choose downloaded and extracted in step 3
Find "jre" and choose the one downloaded in step 2
Accept changes - "Ok" button
Choose "Open"
And choose pom.xml from root directory
After re-indexing and import everything should work correctly

What are the steps to configure Struts 1.3 in Eclipse, with the open declaration and open implementation option on the code?

I've an existing project(in SVN Respository) developed using Struts1. Now I need to import it in the eclipse IDE.
When I try to import the project, I've 2 problems :
If, I place the files from my project to a newly created "Dynamic Web Project", its showing errors with all the javascript, jsp and java files(All import statements are shown as error)
If, I use SVN Checkout/Import, its working fine, no errors. But the links are not available on the java code, like when I click on a function/variable name, it should go the function/variable declaration/definition(Eclipse - Open Declaration/Open Implementation).
Someone please help on this.
I would always prefer to import projects as Maven projects (if they are) so that it would downloads the dependencies on the go.
If the import statements are not recognized means, you should configure the corresponding JRE. This may help you.
Finally, there are so many aspects while configuring an existing project. Please Check your project Wiki if any. If not do create one while you short out them.

How to import a java plugin into your eclipse workspace

I am working on a java plugin and I was wondering if anyone could help me.
I need to import a plugin that goes by the name of "LogBlock" and it has a lot of files if I compile it. So I was wondering if theres a way to import it into my eclipse workspace. (Decompile it and be able to edit it).
Sorry if this question is unclear, if you need any questions about this question answered just say so. Thanks!
The easiest and simplest way to go is to use JD-GUI. A super simple decompiler. Once decomplied there are 2 things you can do:
1 - Import the files into eclipse. This could take a LONG time depending on the files.
2 Recommended - Take the files pop them in a folder named LogBlock and then go to your root folder for eclipse. Open that, you should see all your eclipse projects there. Just drag and drop the folder named LogBlock. When you launch eclipse there will be your LogBlock Java Project. Open it up and you will see a ton of files. Organize them as you saw in JD-GUI.
If you need further help with this I could make a video and give you the link to it.
Java Decompiler will do the trick.
From there you can import those files into Eclipse by right clicking your project, and choosing import from the options menu. You shouldn't be editing a released plugin however..

Java Eclipse Android Beginner Question - How to add libraries or Linked Folder. Beginner References

I'm just starting with Android developmenent using Eclipe and have already run into some basic questions. I have some beginning books such as "busy coders guide to Android..." and "Teach Yourself Android Application Dev't in 24 Hours", however, I'm not seeing some basic things covered.
Can someone tell me how to set up a library and then use it in a project? I have some example code where they have a folder appearing in Ecliple called, "DataGatherLib" Right clicking and hitting properties reveals it is of type "Linked Folder". I suspect this is what I want. So my specific questions are:
1. How do you set up your own library project (Linked Folder if that's appropriate) in Eclipse.
How then, do you use your newly created library in a Ecliple Android Project?
More generally, can someone point me to some good beginner references (books or online tutorials) that cover this. I would think that organizing your code in libaries as opposed to one big application is fairly basic, but I can't seem to find the discussion.
Thanks,
Dave
In Eclipse right-click on your project, select "Properties", then "Android" and you see a page to add a library project.
BTW, you should do the same on the library project and mark it as a library first before you can add.
Alternatively you can drag and drop jars to your project and add them to your classpath, but in this case you can only access class files and not the resource files in the jar.

EdgeType.DIRECTED not working

I recently figured out how to add the Jung libraries to eclipse, but now I ran into a new problem. I'm using the Jung tutorial and I can't seem to run the first tutorial, because the Eclipse IDE is saying that the .DIRECTED ,in the code, cannot be resolved or is not a field. How do I fix this?
edit: Yes, using that package worked! However, I'm surprised that the Eclipse IDE did not offer to import the package for me. Is this unusual?
Make sure to include all the required JUNG2 libraries into your Eclipse project. When you do that, Eclipse will give a few suggestions after you right-click on those yellow-underlined words. Choose the one(s) related to JUNG2 to remove the warning(s).
EgeType.DIRECTED must be imported from edu.uci.ics.jung.graph.util.EdgeType package which is under jung-graph-impl-2.0.1.jar

Categories