Eclipse Package Explorer not matching physical folder structure - java

Newbie question
I have downloaded a project from git repository using Eclipse (Import-> Clone URI).
It created a folder in my local MyDocuments git folder and I can also see the project in the Eclipse's Package Explorer.
For some reason, for any source file, say HelloWorld.java which I see inside the MyDocuments git project folder, I do not see HelloWorld.java in Eclipse's package explorer. I have changed perspective to java/javaee/java browsing etc.
Is there some setting/perspective in Eclipse where I can see all the source files?

After successful cloning git repository inside eclipse, you need to import these project inside eclipse.
Click Windows > Show view > Other then select Git repositories view. Right click on Working directory then select Import project.

Related

Eclipse project structure showing improper project structure

I have set up an eclipse workspace. Inside this workspace i have a dynamic web app cloned from repository. My working directory looks like following.
I am seeing a different hierarchy in Eclipse project explorer. My project explorer looks like following.
Ideally it should show src, WebContent, build.xml etc. inside java resources but it shows entire project folder inside java resources.
Troubleshooting I tried:
1. Delete existing project from project explorer and import the project again.
2. Pull the changes in local copy and refresh the project from project explorer.
3. Change the working directory and import a new project.
None of this seemed to resolve the problem.
Appreciate if someone could help me with the root cause and a solution to this.

IntelliJ Idea generated source

Just new to IntelliJ Idea. I have maven project which has few generated source java files.
When I import that project Idea complaints about generated source files are missing but I can see those files under target/generated-sources. How can I add those files in the classpath.
You can go to Files > Project Structure and then choose your module and on the sources tab you can navigate to the generated-sources dir and click Mark as > Sources:
Additionally, folder could be assigned to the specific type from the Project panel via mark directory as context menu.
To have maven do it automatically, look here: How to create folder for generated sources in Maven?
If you are using Springboot Application.
just follow the step in IntelliJ.
Right-click on project folder.
Select maven.
Generate source and update the project folder

Exporting usable .jar files from GitHub project

I'm rather new to java and eclipse, and I would like to get jar files from this github project:
https://github.com/nikkiii/omegle-api-java
I've tried doing so in eclipse, but I can't import the project as a java project, and (I think) for this reason I am not able to use the Export feature to obtain jar files for the project. What is the easiest/best way to go about this?
Thanks
This is the easiest way, assuming you dowloaded the zip file containg the .java source files from github:
Unzip the zip file into a folder in your Eclipse workspace, say omegle-api-java-master.
In Eclipse, select New->Java Project and name it omegle-api-java-master. Eclipse will create a project from the source in your workspace, and set it up with a java builder.
Import any required jars to get it to compile (for example the project page states you need https://github.com/douglascrockford/JSON-java). You can extract that in your workspace in the same way and then import it into your Omegle project by right clicking on the Omegle project, selecting Properties, going to Java Build Path, selecting the Projects tab, and clicking the Add button.
Once everything is compiling, right click on the Omegle project, select Export -> Java -> JAR file, which will create your jar file for you.
I assume that you have an Android library (downloaded a GitHub repository of the library) and found that it doesn't contain pom.xml. If you have this file, see How to Create a jar file from github project.
Open a folder of the library and add local.properties file with a path to your Android SDK (for instance, sdk.dir=D\:\\Android\\SDK). Otherwise you can see an error: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
In command prompt (cmd.exe) run gradlew build. If it will throw Android exceptions, maybe you should switch to master branch of the library and build again.
If everything was normal see subfolders and look for build\libs folders inside. There you can find jar-files.

How to import and run ivy+ant project in eclipse juno

this is my first use of ivy+ant and after building the project from command line, i want to import it into eclipse juno.
the project folder (trunk) contains the following folders/files:
build
dist
src
WebContent
build.properties
build.xml
ivy.settings.xml
ivy.xml
i tried to import the trunk folder that contains the above files/folder using import existing projects into workspace, but i get the error that no projects found.
pleases advise how to import this project.
UPDATE: i tried to configure the project for eclipse before importing using the following command:
ant eclipse-default
but i get the following error:
Target "eclipse-default" does not exist in the project
UPDATE 2:
i was able to import the project in eclipse as follows
File > New > Other > Java Project From Existing Ant Buildfile
but when trying to run the project on server, i can't find run on server in the run options, please advise.
You may try this:
Install IvyDE from http://www.apache.org/dist/ant/ivyde/updatesite (ref: http://ant.apache.org/ivy/ivyde/download.cgi)
IvyDE may not recognize your setting and properties file. At Window -> Preference -> Ivy -> Settings, check reload the setting on demand, add Ivy setting path ivysettings.xml or your Ivy setting file, Property files build.properties or your Ant properties file.
Add new Java project you want to work on, point the path to your project.
At the new project wizard, Libraries tab -> Add Library -> IvyDE Managed Dependencies.
You can not import a project of you do not have the eclipse project information in your code.
Either create a new eclipse project from existing source.
Or a new java project from ant buildfile (your update 2).
For running need configuration of server (hard to know what youneed there), you may need to create new server (preference/server/run time environnement) (or from view server, right click "new")

Wrong package name when using automatically added imports in Eclipse

I have several Maven projects converted into one Eclipse workspace. When I edit the code under Eclipse, I sometimes use CTRL+SHIFT+M combination of keys to automatically add imports to the classes from a project in my workspace. But somehow they are added like this:
import src.main.java.com.mycompany;
while to real package I wanted to import is com.mycompany.
This has to be some configuration in Eclipse to fix this but I'm confused. However, this issue is very annoying.
EDIT:
I've forgotten to mention that Eclipse files were generated using mvn eclipse:eclipse command.
Under Eclipse project seems to be configured properly. Its source folders set like this:
src/test/java
src/test/resources
src/main/java
src/main/resources
And everything under Eclipse works properly except the situation when I press CTRL+SHIFT+M keys
The standard source folder for Java projects is
./src
For imported maven projects, simply remove this folder from the list of source folders at the build path settigs. The correct source folder is
./src/main/java
In eclipse;
Remove the existing source folders first.
-right click -> menu -> build path -> remove from build path
then
Right click on the source folder.
build path -> use as source folder.
Seems like your settings are pointing to the parent of the source folder so src is recognized as package by eclipse.
It's because eclipse is not aware of the convention over configuration filestructure Maven is following. Install the M2Eclipse plugin and File > New > Other > Maven Project for new projects or for existing ones right click on your imported project on Package Explorer > Maven > Enable Dependency Management. Once successfully done, on the Package Explorer you would see your project nicely gathered following the Maven conventonal filestructure like src/main/java, src/main/resources, src/test/java and from then on you'll start seeing your package structure hierarchy like com.mysite.myproject..
First remove it. Then add it back using right click on package->build path->configure build path-> Source->Add Folder and add the entire /src/main/java tree
You've got the wrong source folders in your build path, and it's a wonder that anything works at all.
You can use either the maven-eclipse-plugin or M2Eclipse to automate getting this right, or you can manually fix the build path to call our your actual source folders, not their great-grandparents.
Non of the above worked for me. Finally I just changed the name of the scr folder to scr-java and this removed the package structure with scr as root package.

Categories

Resources