Need some help importing & rebuilding a Github java project - eclipse

I am attempting to make a little tweak in the source of a GitHub java project and to rebuild it back into resulting .jar file to run.
On the project's URL, README says Download the source and build with gradle.
Downloaded using Clone or download button, extracted
Installed Eclipse 2019-12, then > File > Import > Gradle > Existing Gradle Project..., which gave me
Opened the .java file in the editor to make any tweaks
Now I need some help understanding how can I test and rebuild so I end up with '.jar' file to run? (The GitHub project's already built original .jar files are here)
Would appreciate to learn what further steps to take towards that.

Can you try using gradle wrapper (https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:adding_wrapper), this may resolve the build issues.

Here's how I finally got it working in Eclipse (Windows), thanks to help by emmanuel-chebbi (See detailed discussion in comments below the question)
Created a Windows environment variable JAVA_TOOL_OPTIONS value -Dfile.encoding=UTF8 ( See this )
The file Commons.java in the project also needed to be changed to UTF-8 NOBOM (just UTF-8 not good for Windows!) So did that ( See this )
Imported the project and overridden Gradle 3.0 to be the default ( File > Import > Existing Gradle Project > select dir > next > override > specific gradle version 3.0 > next > finish )
Any code changes as desired, if any (beyond this question's scope)
Ran default Gradle Tasks ( Gradle Tasks Tab > right-click project > Run Default Gradle Tasks )
Two JARs generated in \distrib folder
By the way, meanwhile I have also been trying to get a non-GUI IDE based solution with Gradle 3.0 command line to work, thanks to suraj-muraleedharan, and will update here if I get anywhere with it. (It's good for me to know there's a direct way than GUI IDE, but at this point, I just want to keep it simple for my limitations' sake — so accepting this as answer since it was posted as an Eclipse question anyway.)
Thank you both for your kind help and patience!

Related

How to fix "Missing Gradle project configuration file" issue in Buildship?

As an Eclipse user, I always liked the Gradle IDE. However, this plugin is now deprecated in favor of the new Buildship plugin.
After setting up a fresh Eclipse IDE with Buildship installed, I'm faced with the following error in all my Gradle projects:
missing gradle project configuration file: .settings/org.eclipse.buildship.core.prefs
There are several pages on google that deal with this issue, but all of them seem pretty outdated. There is also an entry in the bugtracker of the plugin which is set to "CLOSED FIXED". Well, apparently, it's not fixed.
Am I doing something wrong? Any ideas how to tackle this issue?
I've figured it out myself. The issue with the "missing gradle project configuration file" arises from the way the gradle project(s) are imported into Eclipse.
When importing a gradle project via the regular File -> Import -> General -> Existing Project into Workspace command, then it will not work and produce the aforementioned error.
However, if you import the very same project via File -> Import -> Gradle -> Existing Gradle Project, then you get a different import wizard, and with this wizard, it works like a charm.
I still think it's a bug because the choice of the import wizard should not matter. Still, choosing the proper wizard is a viable workaround.
Another option is to:
Move to your projects path (where gradle or gradlew is found)
Unix: sh gradlew cleaneclipse
Win: gradlew cleaneclipse
Requires the apply plugin: 'eclipse' in your build.gradle
Refresh your Project in eclipse.
After that for Unix: sh gradlew eclipse Win: gradlew eclipse
Now the gradle nature will be missing in your eclipse-project. Open the context menu of your project -> configure -> add gradle nature
Now everything should be fine again.
I seriously searched for the solution, but only found workarounds. Alan47's solution created the file for me, but couldn't create the project properly in my case. So I just copied the file created and imported the project again in the default way:
File -> Import -> General -> Existing Project into Workspace
and pasted the file again at the directory
./.settings
The name of the file:
org.eclipse.buildship.core.prefs
The content of the file is only:
connection.project.dir=
eclipse.preferences.version=1
The easiest solution, using just the mouse
As is told here by oehme (Stefan Oehme - core dev):
https://github.com/eclipse/buildship/issues/504
"Buildship can't recreate that file as it cannot know what your root project was (Gradle supports arbitrary project layouts). You should either check the settings file in or not check in any Eclipse files at all. Checking in .project while leaving out .settings is not supported."
Or here (Stefan Oehme - core dev):
https://discuss.gradle.org/t/do-i-need-to-check-in-settings-org-eclipse-buildship-core-prefs-file/22457/2:
"This would happen if you have a checked in .project file with the buildship nature, but no checked in settings file. The choice is between checking in both or checking in neither and using the Gradle import wizard."
The easiest solution, using just the mouse is the following:
Right click on the project then click Properties
In the properties window go to the Project Natures and remove the Gradle Nature then click Apply and Close button
Open again the same window and add Gradle Nature back, then click Apply and Close button
Right Click on the project > Gradle > Refresh Gradle project
After each step: 1,2,3,4 let eclipse do its update job, do not push it quickly.
Other solution is to have the file saved somewhere and paste it again in the project or create from scratch manually, then do: Right Click on the project > Gradle > Refresh Gradle project.
Useful details:
File name: org.eclipse.buildship.core.prefs
File usual encoding: ISO_8859_1
File path: ./setting/org.eclipse.buildship.core.prefs
File content, one line: connection.project.dir = eclipse.preferences.version=1
maybe you can use this method. by making the file back
I accidentally deleted or lost the file in my flutter project.
then I make a new method
enter the ./android folder in your flutter project.
copy to your terminal for mac:
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
then to your ./android/app folder in your flutter project.
touch "org.eclipse.buildship.core.prefs"; echo "connection.project.dir=..
eclipse.preferences.version=1" >> org.eclipse.buildship.core.prefs
Step 1
Right-click on your project name in IDE > Properties > Project Natures > Choose Gradle Project Nature on the right pane > Remove > Apply and Close
Step 2
Right-click on your project name in IDE > Configure > Add Gradle Nature
Result
Give it a few seconds for Gradle to synchronize with the IDE, and
.settings file will be automatically generated in the project root.
Delete error
Delete the error in Problems view.

Sample Project Import in WSO2CEP Developer Studio fails

I have just installed eclipse-luno-with-developer-studio and in need to make some changes in already created samples in wso2cep like the very first one, http but it isn't importing those samples. I can run those samples using
ant -Durl=http://localhost:9763/endpoints/httpReceiver -Dsn=0001
but I want to modify the source and try again. For that when I searched, I found above IDE but its not accepting these samples as project when I try to import it. Anyone with a clue?
Please refer importing ant build.xml in eclipse.
Open Eclipse, select File > New > Project
Select "Java Project from Existing Ant Build File"
Show your build file and write a project name
For step 3, select the build.xml file related to the sample-project which you're trying to import.
For example, if you're trying to modify the HTTP producer, then you can point to following ant build file:
<CEP_HOME>/samples/producers/http/build.xml

Open "gradle" project

I am an Android beginner and I downloaded the DisplayBitmaps project from the following link:
http://developer.android.com/training/displaying-bitmaps/index.html
It seems that there are no java files under the "src" folder but i find some codes under the folder "java" and a new item called "gradle".
I googled "gradle" and downloaded the eclipse plugin as suggested by the following link:
http://forums.gradle.org/gradle/topics/gradle-2-3-released
In Windows cmd, i have checked that gradle has been installed in my computer but i just don't know the next steps required in order to execute the project. I searched a long time and a bit confused by the solutions posted online.
It seems that gradle is q common but there are not many well documented tutorials on importing gradle into eclipse. It will be great if anyone would share some useful materials, many thanks in advance.
Install Gradle Eclipse plugin from this update site: http://dist.springsource.com/release/TOOLS/update/3.6.4.RELEASE/e4.4
(The update site is for Eclipse 4.4.x, put 4.5 at the end of URL if it's Eclipse 4.5 you are using)
Once installed import project as Gradle project. Don't forget to click on "Build Model" in the import wizard once you point to the right folder where the project to import is.
Once Gradle project is properly imported it'll have java nature applied to it and it'll have the appropriate folders...

How do I open the GWT samples in eclipse Helios and GWT 2.1.1?

What is the straight-forward way of importing one of the GWT samples in eclipse Helios + GWT 2.1.1. It seems like the content of the zip file doesn't contain any project files for eclipse.
I tried the following:
create a GWT project 'bla'
Delete the src ad war folder and
replace it with the src and war
folder from the sample
refresh the project in eclipse
hit 'run'
[ERROR] Unable to find
'bla/bla.gwt.xml' on
your classpath; could be a typo, or
maybe you forgot to include a
classpath entry for source?
So I go to the run configuration and remove the path for the example projects from the arguments list. I also changed the name of hosted html page to the one in the sample. Hit 'run' and:
[ERROR] Invalid version number "2.0"
passed to external.gwtOnLoad(),
expected "2.1"; your hosted mode
bootstrap file may be out of date;
Now I need an out of date version of GWT to run these samples? What is going on, I just want to look at a sample to learn a new concept.
Reading the readme.txt in the GWT samples directory I came across a solution that works on Eclipse 3.7. Assuming you have ant installed on your machine, execute the following from the sample's directory:
ant eclipse.generate
This will generate both the .classpath and .project files needed to import the sample into Eclipse and run it.
Here the relevant excerpt from README.txt:
-- Option A: Import your project into Eclipse (recommended) --
If you use Eclipse, you can simply import the generated project into
Eclipse. We've tested against Eclipse 3.4 and 3.5. Later versions
will likely also work, earlier versions may not.
If the directory containing this file does not have a .classpath or
.project file, generate them by running 'ant eclipse.generate'
In Eclipse, go to the File menu and choose:
File -> Import... -> Existing Projects into Workspace
Browse to the directory containing this file, select "Mail".
Be sure to uncheck "Copy projects into workspace" if it is checked.
Click Finish. You can now browse the project in Eclipse.
To launch your web app in GWT development mode, go to the Run menu and
choose:
Run -> Open Debug Dialog...
Under Java Application, you should find a launch configuration
named "Mail". Select and click "Debug".
You can now use the built-in debugger to debug your web app in
development mode.
In eclipse 3.7, instead of Run -> Open Debug Dialog..., its Run -> Debug Configurations. I got both the showcase and mail samples running following those commands. Should work for all of the other samples as well.
The examples that come with GWT SDK were built in different ways. Some are Maven builds, others use Ant. Eclipse can handle these common builds directly, but you have to choose the right option.
So, if you want to open the Expenses project in eclipse, you would look in the projects root directory (i.e. ../gwt2.4/samples/Expenses) where you'll find a file called pom.xml. That is a Maven build file. To import it into your Work space select:
File->Import...
Open Maven->Existing Maven Projects, and click on Next > button
Browse your file system til you reach the Expenses folder. Click on it and Select OK.
At this point it will show you the Projects in that directory in the Projects: area of the window...only one in this case: /pom.xml com.google.gwt.sample.expenses:...etc.
click on the checkbox for that project, Next>
Finally, it ask you to map plugins. You'll need to select in the drop down menu under Actions the required plugins (such as m2e).
In other project folders you may find a build.xml file instead. That's an Ant build file. To import that you do something similar, but different (of course!):
File->New->Project...
Open the Java folder and select "Java Project from Existing Ant Buildfile", Next >
Click the Browse button, dig through your directory to the project folder and select the build.xml file, and Open it.
Project name should fill in automatically, just select the declaration to use in the middle window and click Finish.
Since those tutorial only include the src and war directory, the idea remains to:
create a new project following this tutorial
remove any created class part of the example files which are automatically added (see Issue 1547)
Unfortunately the Google Plugin does not allow to created a new Web Application Project without creating template files. The template files are nice for the first try but annoying if you want to start from scratch with a new GWT application.
copy the src and war directory in place within the now empty project
Following your ticket 5847 (No easy and straight-forward way to make examples work in eclipse),
as xo4yhamope comments, you need the right GWT option.
and did you consider the Issue 5038 about the error message:
Unable to find 'xxxx.gwt.xml' on your classpath;
could be a typo, or maybe you forgot to include a classpath entry for source?
This message usually means you attempted to refresh the browser before dev mode has had a chance to finish loading the module.
The uppercase/lowercase confusion happens because the module has been renamed to 'stockwatcher', but dev mode cannot map 'stockwatcher' to "StockWatcher' until it has finished loading the entire module.
So, it's just a matter of waiting a few seconds longer after the Development Mode pane says I should go to http://127.0.0.1:8888/StockWatcher.html?gwt.codesvr=127.0.0.1:9997 ?
That seems a little messed up. It should wait until it's actually ready before telling me it's ok, because users (like me) are going to go there as soon as the UI says it's ready.
The other confusing part is that the server begins serving the host page as soon as that message in the UI comes up. Because this was happening, I assumed that the server was completely up, even though (as it turns out) it wasn't.
Anyway, waiting a few more seconds seems to resolve the "Unable to find 'stockwatcher.gwt.xml' on your classpath" problem. Thanks!
I'm beginning to suspect this is a bug in the samples. I am adding this answer so it can be marked as an answer when I get confirmation about that.
I was trying out some other samples and came across this page. At the top is a little explanation for how to download and import the sample.
Before you begin
The StockWatcher project
This tutorial builds on the GWT
concepts and the StockWatcher
application created in the Build a
Sample GWT Application tutorial.
If you have not completed the Build a
Sample GWT Application tutorial and
are familiar with basic GWT concepts,
you can import the StockWatcher
project as coded to this point.
Download the StockWatcher project.
Unzip the file.
Import the project into Eclipse
From the File menu, select the Import... menu option.
Select the import source General > Existing Projects into
Workspace. Click the Next button.
For the root directory, browse to and select the StockWatcher
directory (from the unzipped file).
Click the Finish button.
If you are using ant, edit the
gwt.sdk property in
StockWatcher/build.xml to point to
where you unzipped GWT.
Now this is what I call straight-forward and easy.
At that point I had already built the StockWatcher in a previous tutorial but I got intrigued by the fact that it was explained exactly as I tried it the first time. So I downloaded the project and it had the correct eclipse project structure. I tried to import it 'et voila' I have the project in eclipse. I runs out of the box (with warnings). That is how expected the samples to be.
This experience leads me into thinking that the sample projects are malformed (as eclipse projects) and need to be updated. Let's hope my issue report leads to results.
-- Option A: Import your project into Eclipse (recommended) --
If you use Eclipse, you can simply import the generated project into Eclipse.
We've tested against Eclipse 3.4 and 3.5. Later versions will likely also
work, earlier versions may not.
If the directory containing this file does not have a .classpath or .project
file, generate them by running 'ant eclipse.generate'
In Eclipse, go to the File menu and choose:
File -> Import... -> Existing Projects into Workspace
Browse to the directory containing this file,
select "Mail".
Be sure to uncheck "Copy projects into workspace" if it is checked.
Click Finish.
You can now browse the project in Eclipse.
Copy from readme.txt supplied by samples. I tried this method, it's OK.
To import GWT showcase(2.5.1) I did following steps:
Create a new Google Web Application Project
New –> Other –> Google –> Web Application Project
Provide the project name “Showcase” and the Package name is com.google.gwt.sample.showcase
Click Finish
Go to eclipse plugin folder and traverse to the gwt
Under that folder go to gwt-2.3.\samples\Showcase
Copy (Ctrl C) all the contents. The contents are
a. src
b. test
c. war
d. build.xml
e. README.txt
In the eclipse, right click on the Showcase project and paste. Overwrite all the files
The files should start copying without any problem
Right click on the Showcase and Run As “Web Application”
You should have your Showcase working like Gem!
For me it worked like a charm ;)
Ref : http://simplestepswebdev.wordpress.com/2011/05/16/import-gwt-samples-into-eclipse/

Red exclamation mark in Eclipse with mercurial

I have imported a project with Mercurial (hg clone ...).
When opening it with Eclipse, a red exclamation mark appears by the project's name in the Project Explorer, and it cannot be built. Silly messages like "import java.util cannot be resolved" appear, and errors in files are not marked in the Package Explorer.
How can I resolve this?
Check the problem view. By exclamation it is usually means a problem with build path
Check the Build Path of the project by right clicking the project and select Build Path -> Configure Build Path.
One problem I often encountered is different people using different Java SDK and so when the exact SDK is not available in your machine, you need to change to your Java SDK (via JRE System Library -> Alternate JRE). A better way to avoid this problem is to always select the JRE System Library from Workspace default JRE or Execution Environment.
I solved the problem by adding the external .jar file in to my project.
RightClick on the project -> Properties -> Java Build path -> libraries tab -> Add jar
Select your jar file and added it
Thats it the red ! mark gone.
Some times it happens that you have added a jar file earlier but currently not using it. Then after some time you delete the jar file from your system. But since you are not using the library file, so you will not get any error.But then you will see the red exclamation mark for the project. So all you need is to remove the added jar from the Build Path.
Done.....
The Java Runtime Library was defined wrong for the pulled project.
It had to be reset under Project | Properties | Java Build Path | Libraries.
It means there is a problem with the build path in your project. If it is an android project then it mostly means the target value specified in project.properties file cannot be found. This can also be caused because of other kinds of built problems. But it is shown mostly for built problems only. See here for more details. It is about built error decorater seen in eclipse.
An extract from that page:
Build path problems are sometimes easy to miss among other problems in a project. The Package Explorer and Project Explorer views now show a new decorator on Java projects and working sets that contain build path errors:
The concrete errors can be seen in the Problems view, and if you open the view menu and select Group By > Java Problem Type, they all show up in the Build Path category:
I figured out each time i am trying to import a library into my android project, i have a red exclamation mark with both ActionBarSherlock and Facebook libraries
This is how i solved it:
After adding the library into your project "project properties->Android->Librairy->add"
If you are using Eclipse, all you have to do is to clean your project and build all your workspace:
"project -> clean... -> "clean selected project" -> build the entire workspace
For me, the problem was a simple one - the reference project was compiled in 1.5 and my project 1.6. Matching the two solved the issue.
Right-hand-click on the project, select properties, select java compiler.
This is how I solved this problem:- Right-Click to project->properties->Java Build Path->Libraries(tab)->Remove the Jar which is already present there with a Path given along.