The Java files opened by Eclipse's menu "open file"does not auto-build - eclipse

Eclipse has a nice feature that builds your codes on the fly.
However, for some reason, I have had a source .java developed in Emacs under some directory, say, ˜/mycode. Now I want to use the auto builds functionality of Eclipse, but I do prefer to develop the .java file under its original ˜/mycode directory. So apparently, I CANNOT use "import" of Eclipse because that means the file will be henceforth developed under some Eclipse Workspace.
This is the reason why I have to use Eclipse's menu's "open a file" to open my file from ~/mycode.
Then the problem comes, no more auto-build for this .java file!! For example, if I write one line like "abcd;;;;;" I will not get this line underlined by the syntax checker of Eclipse.
In summary, I would like to continue developing a code under its original directory, and also benefit from the auto-build functionality of Eclipse. What can i do? Thanks.

Related

How do you open an existing .java file and compile it in eclipse?

I am just starting to consider using Eclipse, as I hear it is a very good debugging tool and excellent IDE. I have a .java file which I had written in JCreator and have saved in my Google Drive directory. However, I am having problems running this file within Eclipse. If I open Eclipse and then open my file, a few things happen. First, a .metadata folder appears inside my Google Drive. Second, the file opens, and I can edit and save changes. However, if I try to compile the file, I get a "Run As" popup window with the options "Ant Build" and "Ant Build..." Selecting either results in a "Build Failed" error.
I have a few questions:
1) What is the .metadata folder and why does Eclipse create it?
2) How do I open an existing .java file in Eclipse?
3) What is an "Ant Build"?
Sorry if these questions are very basic, but a search through online tutorials has only told me how to create and compile projects with Eclipse. If I start a project in Eclipse, then everything works fine, but otherwise, I can't get anything to work at all.
I do not know, but a simple Google search led me to this question and this other question which might be of help;
I don't know if it is possible to just open a file without starting a project, but once a project has been started, it is relatively easy to import a file: File>Import, find the directory, check the files you want to import, select import directory and go ahead. Now I haven't managed to run a program with GUI after importing because apparently it has problems loading classes like JFrame because of a restriction in the library, but I have imported and run a simpler program; oh, and when you import, you select General, then File System;
Try googling for Ant Build. I fount a few sites mentioning "Apache Ant", which seems to be related to GUI building.

How to activate features of EPIC Perl plugin for Eclipse

I just downloaded the EPIC Perl plugin for Eclipse and then opened a Perl script (.pl) contained within an existing C++ project. The editor does not have syntax highlighting or any of the other promised features of EPIC. The only thing that has changed is that the script has a camel icon in the Project Explorer.
I open a different .pl file in a different directory within the same project and it works (syntax highlighting).
How do I activate the features of EPIC for the first file?
I'm using Eclipse Kepler on Windows 7.
(the only thing I can think of is that the first file was open in Eclipse before I installed the plugin, the second file was not. But closing/reopening the file and/or Eclipse does not fix the problem)
Right-click on the the file in the Navigator, choose "Open With" and then "Epic Perl Editor".

Solution/project file for Java IDE

Is there a way to make a double-clickable solution/project file using a Java IDE such as Eclipse or Netbeans, in the same way as the .sln files of Visual Studio?
So that when I move my source code between computers, all I have to do is double-click on the solution/project file and the project will be automatically loaded?
Open eclipse, in Menu file->Import, you can find some useful menu-item to open a java project.
In fact, Some times NO project file you want.

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/

Open file in eclipse on mac 10.6

I have a deceivingly (at least for me) simple problem. I want to open a file in eclipse FROM Mac's finder. Whenever I try, I get the alert that Eclipse cannot open that file. Yet, from within Eclipse I can open the file, either by double clicking it in the Explorer/Navigator window or going file/Open File ...
At the end of the day, I want to be able to open a file in Eclipse by specifying the path name to that file.
Eclipse build id: Build id: 20100218-1602, with IDE for PHP Developers installed
Yes, this is something that should be simple, but it is not. The reason is that Eclipse uses the workspace as a way to abstract from the filesystem. The workspace is often similar to, but different from the file system. For one thing, only files within a certain project in the workspace are really known by Eclipse. Another difference is that a single file in the file system can be linked into the workspace and appear multiple times.
All this is to say that since the mapping from the file system to the workspace is not one-to-one, it is not easy to open any arbitrary file in the file system into your Eclipse instance.
That being said, it is possible to drag and drop a file from the finder into the editor pane. Eclipse will then attempt to open the file using whatever is the default editor for that file type.
So, dragging and dropping a Java file will open a Java editor for it (even if the file is not in the workspace), but dragging and dropping an HTML file will open it in whatever browser is set as Eclipse's default.
I think that is imposible in Eclipse.
For separated files you can use "textmate", it's fast and powerful.