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

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/

Related

How to use SVN to build a library

I am trying to follow a tutorial, and I am told to:
1- Get the source code for the Java EMV Reader library from http://code.google.com/p/javaemvreader/ and build it.
2- Drop the resulting jar file in lib/.
3- Import the project in Eclipse and build it.
I right click the java files, and choose run as but don't get an option to run as Java Application. I also can not export the files as a JAR file. I have enclosed an image of what I have
After the first comment, I right clicked on my project, and under Maven, chose the option "configure as Maven" project. ( Thank you so much; this must be one of the fastest resolutions in the world )And I can now run the project. I get the window in my pic2, which I have attached. I don't however know what step 2 of the above instructions means. I don't see a lib/ folder. And the project he is refering to in step 3 is on git. Any ideas on what he means? ![pic2]!1
Eclipse projects have a "type" and that controls what tools are available. You probably created a "Basic Project" which means there are no compilers or other Java tools associated with it. You would want to create a Java Project in Eclipse.
That project does not seem to have Eclipse .project and .classpath files checked into the repository. It does look to be a Maven project however. So you would either want the m2eclipse plugins installed, and check this out as a Maven project, which would handle configuring everything else, or you want to use the Checkout As ... option and use the wizard to create a new Java project to checkout.
These are more Eclipse IDE questions than SVN or Subclipse questions.

How do you configure eclipse to work with a project that wasn't created by it (java)

I have been using the text editor gedit and the terminal for my latest project but I find that I have so many classes it would be more useful to be working with a separate directory for my .class and .java files so I can see what is going on more easily.
Unfortunately I have not been able to figure out how to get eclipse to work with a project that has already been made (or even one that was already made on eclipse with another computer!). This was not such a problem with two or three classes but I am getting to have so many that it is really tedious- It seems to want me to build a completely new project or nothing.
EDIT (additional info):
I don't think it will be possible to show the code of the project as I current have 12 classes for it but by the end I may have one or two more...
I know how to make a project in eclipse. What I am not sure how to do it open a directory full of .java files in eclipse that were created using a text editor rather than in an eclipse project and get eclipse to accept it as a project.
Does anybody know how to achieve this task?
You can import your project into eclipse doing the following steps:
Create a new Java Project in Eclipse (By going to File -> New -> Java Project) select a name for the project and you can select finish
You have to import your existing code to eclipse, go to:
File -> Import -> General -> FileSystem
Then browse to the directory where your code is currently, and say you want to import into the project you created in step 1
Afterwards remember to go to the project properties (right click in the project folder while in the navigator view, for example) and make sure the java build path has the right source folders configured.
Fortunately, you can use eclipse for any project previously created. Do you possibly have the code to show us how you are applying to the project in eclipse?
For example, you can create a project and class, then copy over starting from public static void main(String[] args) {
down to the bottom, then import the important stuff above the main class name.

.class file opens instead of .java while debugging

Current setup:
MainProject which is a Library Project
BranchProject which is a new projects and has MainProject as a Reference
Whenever I debug and a file from MainProject is on focus (actually BranchProject has only graphic and xml layout changes) the Debug window opens a .class file which is read only. I want it to open the .java file so I can edit it directly.
Skyler's answer from this post worked for me:
Opening source code from debug view edits .class after Android R18 update
Here is a summary:
The fix is to right click the Project name in the debug view, and select "Edit Source Lookup..." from the menu. From there, remove the Default lookup path. After that, manually add the associated projects (not jars) that your project references. This is done by clicking Add, selecting Java Project, then checking the appropriate projects.
When you're using a Library project one of the things you're in fact doing is compiling your Library project into a jar and then referencing that jar in your calling Project.
If you right click the Project, and select "Configure Build Path" you'll see a tab called "Libraries", if you look inside "Android Dependencies" you'll notice a list of jar's corresponding to your Library projects.
These jars are expandable, showing you that they have a slot for a source attachment. Usually this would be editable allowing you to directly link the source but in terms of ADT these are already filled and are uneditable.
When debugging these files you're linked to a read-only class file with this attached source. This is because you're not running against source files directly, you're running against a pre-compiled class file. Until the ADT team get this functionality in place, you're pretty much forced to jump to the direct source code and rebuild everything.
EDIT
See #Steven linked answer :)
I faced the same issue while debugging the a .java file using Eclipse IDE. As per my understanding this issue comes when we put the xyz.class file of xyz.java file or JAR at the project build path. Delete the .class or JAR file from the project class path and rerun .java file in the debug mode. This time you see a source not found window. Click on "Source not found" button and check "Find duplicates..." at the bottom of the window. Done your problem is solved :)
The problem is that the class file is preferred over the java (by default), here is how you can change that for Eclipse (tested on NEON 2):
Right-click on the Project in the Project-Explorer, click Properties
On the new window select: Run/Debug Settings
Create a new configuration (or duplicate another one)
Select the new config and click Edit...
Go to the tab Source
Select the Default and Remove
Create a new path with Add..., select Java Library, then JRE System Library
Create a new path with Add..., select the location where the sourcecode is by Workspace folder (if it is a project in the same workspace) or File System directory (it it is not)
I think this depends on, how you set up the dependency in eclipse. You should set up your BranchProject to depend on the source-Files of your MainProject. If you depend on compiles Class-Files is obvious that the debugger opens the class files, because it does not know about the source files.
I found a good solution for me here:
Using Android library in eclipse and jumping to class files instead of source file that is within eclipse workspace
Simply, select each library project your project depends on, and use Top or Up to move it above the projects outputs. Eg. move all library projects to the top.
Open main project properties -> Java Build Path -> Projects tab and add there projects the main project depend on.
Switch to Order and Export tab and uncheck Android Dependencies
Enjoy
If you tried all above hints and it still doesn't work try this solution, it worked form me:
Right-click on the Project in the Package-Explorer, click Build Path -> Configure Build Path...
Select tab Order and Export
select library that you can't reach code and then click on button Bottom
Then click on Apply and Close
hope this can help you
Most of the time it happens when specific source folder are not added in build path Sources tab.
Right-click on the Project in the Package-Explorer, click Build Path -> Configure Build Path -> Source Tab
Add the source folder if your project source folder is not there.
Select Add folder -> select your project source folder specifically. Eg: project_name/src . Then Apply it and restart server.

pydev - setting up an existing python27 project complete with dlls and nested source folders in eclipse indigo

I am trying to set up a project in Eclipse Indigo with pydev on windows 7 Pro SP1 x64. The project exists in my drive (downloaded via tortoise svn) and has the following structure :
root\
launcher.pyw
settings.ini
modules\
__init__.py
module1.py
module2.py
...
more_modules\
__init__.py
moduleA.py
moduleB.py
...
compiled\
1.dll
2.dll
...
I have successfully imported the project in eclipse - specifying root/ as the project folder - and when I right click on the launcher.pyw and run the file the program runs alright (it is a gui application). I have 2 (main) issues :
I want to be able to run the project normally (tell eclipse that when I run the project I actually mean run the launcher.pyw) - when I right click on the project > Run as > Python-unit-test is the only option
I have, say, in more_modules\moduleA.py something like from .. import module1 which shows as an error - so how should I set it up correctly ?
Not sure about the dlls folder also - and not sure about the code analysis - aparently I have to open a file to see the errors - but those belong to another question maybe
The project sourceforge page is : http://oblivionworks.svn.sourceforge.net/viewvc/oblivionworks/Programs/Wrye%20Bash/
The root/ is Mopy/
Edit: moved the picture from my comment:
Regarding launching, you can simply open the file and press F9 to run it. After that, if you've set to rerun the last launch in the preferences (see instructions at: http://pydev.org/manual_101_run.html), you can simply press Ctrl+F11 to rerun it.
I took a look at your sf page and noted you didn't commit the .project and .pydevproject files (please do, so that anyone using PyDev can get things configured directly).
Regarding your import error in the code analysis, it'd be nice if you can actually provide the real example (from your description the error is that you have a '.py' in the end of the module that probably shouldn't be there, but it may be just a description... if it runs and code-analysis doesn't get it, please create a project with that use case and attach it in a bug-report in the pydev sf tracker).
As for the code analysis, usually you really have to open a file to see errors, but you can also right-click a folder and choose pydev > code analysis and it'll do a code-analysis for all the files beneath that folder that are a part of your pythonpath.

gwt> importing a sample project

I'm just barely after 2 hours of trying to force it to work and looking for answers online.
How in the world do you import a sample gwt application into your eclipse and make it run?
by the way, I cannot find "projectCreator.cmd" anywhere in my files, where is it suppose to be assumming i've used eclipse plugin updater to d/l gwt 1.7.1?
Well, this is what I ended up doing though it ugly and probably not how it was meant to be:
I create a new application called it "bla" or whatever
then right on project > import... > general\file system... (as in import files into projects)
then I selected the top folder of one of the sample applications, for example ..gwt..samples/Mail
selected all folders and files.
selected option "override without warning\asking"
de-selected option "copy entire folder structure"
that's about it. I went to build.XML to rename the project name to "bla" and then I clicked run as a web application.
good luck.
For GWT 2.4: In every project's root you will find a README.txt. If you follow its directions (involving creation of Eclipse project configuration via Ant) you can import the project easily. To run it I additionally had to configure the project's GWT settings (project's context menu -> Google -> WebToolkit settings).
First, Create an Eclipse project for your source, if you haven't already done so, by selecting File > New > Java Project. Then choose Create project from existing source and set up your project. At this point, your source will be loaded in Eclipse, but the project's build path may not be set up properly, and you may see build errors.
Alternatively, if your application's source tree already contains a .project file, either because you had previously worked on it in Eclipse or because it was generated by a tool like GWT's webAppCreator, you can import the project by going to File > Import > General and selecting Existing Projects into Workspace
To enable Google Web Toolkit, right-click your project and select Google > Web Toolkit Settings. Check the Use Google Web Toolkit box and click OK to apply the change.
Enabling App Engine for your project is similar: right-click your project and select Google > App Engine Settings. Check the Use Google App Engine box and click OK.
Source : https://developers.google.com/eclipse/docs/existingprojects
What I did to start it:
My workspace is at: /Users/ievgennaloiko/Documents/helpdesk/
I have downloaded the gwt to Downloads folder. Extracted it. Navigated from terminal to samples and run
ant eclipse.generate
for each sample project I need to import to Eclipse. Even you can run this command on whole sample project.
Next I've copied the samples folder to /Users/ievgennaloiko/Documents/helpdesk
Started Eclipse.
File import -> Existing proj into ws -> /Users/ievgennaloiko/Documents/helpdesk/samples/DynaTable
Copy project into ws - Unchecked.
Next I had to go to properties of the project Google-WebToolkit->Use web toolkit.
Here are the arguments I run with, check for correspondence:
-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -port
auto - codeServerPort 9997 -war
/Users/ievgennaloiko/Documents/helpdesk/samples/DynaTable/war
com.google.gwt.sample.dynatable.DynaTable