33 Eclipse Tips

Eclipse is a free software / open source platform-independent software framework for delivering what the project calls "rich-client applications", as opposed to "thin client" browser-based applications. So far this framework has typically been used to develop IDEs (Integrated Development Environments), such as the Java IDE called Java Development Toolkit (JDT) and compiler that comes as part of Eclipse (and which are also used to develop Eclipse itself). However, it can be used for other types of client application as well, including C, C++, COBOL, Python, Perl, PHP, and others.

These are the some of the tips, which can help to build better applications using Eclipse platform.

1) Installing a Plug-in

Download the plug-in, and expand it in the Eclipse plugins directory. Numerous plug-ins are available already, and many are free for the downloading. To install a plug-in, stop Eclipse if it's running, and download the plug-in to the eclipse directory, the directory that contains the workspace and plugins directories.

Eclipse plug-ins come zipped or tarred, and you typically uncompress them in the eclipse directory. When uncompressed, the files for the plug-ins are stored automatically in the plugins and features directories.

Each plug-in gets its own folder in the Eclipse plugins directory. Typically, you'll find the following files in every plug-in's folder:

*.jar

The code for the plug-in, stored in a .jar file

about.html

Shown when the user requests information about the plug-in

icons

Directory for icons (the standard is GIF format)

lib

Holds library .jar files

plugin.xml

The plug-in manifest, which is what describes the plug-in to Eclipse

plugin.properties

Holds text data used by plugin.xml

Note: Although you usually uncompress plug-ins in the eclipse directory, some plug-ins are designed to be unzipped in the plugins directory. If installation instructions for the plug-in are unavailable, open the plug-in using an unzip or untar tool, and take a look at how it'll expand itself—the file plugin.xml always has to go into a subdirectory of the plugins directory.

That's all you need to do to install a plug-in. After expanding the plug-in's compressed file, start Eclipse again. You might see a dialog indicating that configuration changes are pending; restart Eclipse again if necessary.

2) Creating plugin.xml

You want to do the minimal work required to create a new plug-in.

At a minimum, every plug-in needs a plugin.xml file that tells Eclipse about it. And if you have a plugin.xml file, you have a plug-in—even one that doesn't have any code. Start off plugin.xml with a standard XML declaration, add a <plugin> element, and set the id, name, version, and provider-name attributes of this element. Then store plugin.xml in a folder in the plugins directory to install this rudimentary plug-in.

To get a handle on how Eclipse views plug-ins, we'll create a minimal plug-in now, which has only a plugin.xml file. This file is called the plug-in manifest, and it tells Eclipse all about the plug-in and where to find the Java support code, if any. Because, as far as Eclipse is concerned, all you need to create a plug-in is a plug-in manifest, we'll create one now as an example.

Use any text editor that can save plain text, including Eclipse, to create a plug-in manifest for a plug-in named diq.example1.simple. Here's what plugin.xml looks like when specifying the plug-in's name, ID, version number, and provider name:

<?xml version="1.0" encoding="UTF-8"?>
<plugin
id="diq.example1.simple"
name="Simple Plug-in"
version="1.0.0"
provider-name="Plug-in Power Corp.">
</plugin>

Plug-ins are stored in the eclipse/plugins folder, in folders reflecting their name and version number. To indicate that we're creating version 1.0.0 of this simple plug-in, store plugin.xml as eclipse/plugins/ diq.example1.simple_1.0.0/plugin.xml, then restart Eclipse.

This new plug-in doesn't do anything, but to confirm that Eclipse is treating it as a bona fide plug-in, take a look at the plug-in registry, which you can open by selecting Help-> About Eclipse Platform and clicking the Plug-in Details button. You'll see the new, simple plug-in in the plug-in registry.

That provides an introduction to working with plug-in manifests.

3) Add a folder to Java build path as library, having multiple jars or entries in it.

You should define a new ClasspathContainer by implementing the org.eclipse.jdt.core.classpath.ContainerInitializerextension point. For example the org.eclipse.jdt.junit plugin defines the following in its plugin.xml

 



<extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
<classpathContainerInitializer
class="org.eclipse.jdt.internal.junit.buildpath.JUnitContainerInitializer"
id="org.eclipse.jdt.junit.JUNIT_CONTAINER">
</classpathContainerInitializer>
</extension>

The referenced JUnitContainerInitializer creates and initialises the two JUnit classpath containers.

Following this approach you can implement a "folder container".

Update: It is possible to define a container without registering the extension point, but you have to be aware that you'll not have access to lifecycle methods to refresh the container if the contents of the folder change. It is much better to do it via the extension point.

The example below will add the "lib" folder of a project as a custom container, and add any jar files found in the folder as entries within the container. It does not manage source associations.

final String description = "My container";

IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject("foo");

//get the lib folder, TODO check if it exists!
final IFolder folder = project.getFolder("lib");

//define a unique path for the custom container
final IPath containerPath = new Path(
"my.custom.CLASSPATH_CONTAINER").append(project
.getFullPath());

IJavaProject javaProject = JavaCore.create(project);

//create a container that lists all jars in the lib folder
IClasspathContainer customContainer = new IClasspathContainer() {
public IClasspathEntry[] getClasspathEntries() {
List<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
try {
// add any members that are files with the jar extension
IResource[] members = folder.members();
for (IResource resource : members) {
if (IFile.class.isAssignableFrom(resource
.getClass())) {
if (resource.getName().endsWith(".jar")) {
entryList.add(JavaCore.newLibraryEntry(
new Path(resource.getFullPath()
.toOSString()), null,
new Path("/")));
}
}
}
} catch (CoreException e) {
// TODO handle the exception
e.printStackTrace();
}
// convert the list to an array and return it
IClasspathEntry[] entryArray = new IClasspathEntry[entryList
.size()];
return entryList.toArray(entryArray);
}

    public String getDescription() {
return description;
}

    public int getKind() {
return IClasspathEntry.CPE_CONTAINER;
}

    public IPath getPath() {
return containerPath;
}

    @Override
public String toString() {
return getDescription();
}
};

//register the custom container so when we add its path it is discovered
JavaCore.setClasspathContainer(containerPath,
new IJavaProject[] { javaProject },
new IClasspathContainer[] { customContainer }, null);

IClasspathEntry[] entries = javaProject.getRawClasspath();

//check if the container is already on the path
boolean hasCustomContainer = false;

for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER
&& entries[i].getPath().equals(containerPath)) {
hasCustomContainer = true;
}
}
if (!hasCustomContainer) {
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];

    System.arraycopy(entries, 0, newEntries, 0, entries.length);

    // add a new entry using the path to the container
newEntries[entries.length] = JavaCore
.newContainerEntry(customContainer.getPath());

    javaProject.setRawClasspath(newEntries,
new NullProgressMonitor());
}

Actually we have to implement it without using plugin.xml, we need to implement it with java code only.....The library folder should have the ICON like JRE library in libraries tab of java build path. And the jars will be shown after expanding the library name.

4) Useful Eclipse features

Most commonly used features are

ctrl-1 quick-fix / spell-checker

opening files

    * ctrl-shift-t load class file by classname
* ctrl-shift-r load any file by filename

matches are made on the start of the class/filename. Start your search pattern with a * to search anywhere within the filename/classname.

Formatting

    * ctrl-shift-f Format source file (set up your formatting style in Window | preferences | java | code style | formatter)
* ctrl-shift-o Organise imports

Generated code

    * alt s r to generate getters and setters
* alt s v to insert method signatures for overidden methods from superclass or interface

Refactorings

    * alt-shift-l Extract text-selection as local variable (really handy in that it determines and inserts the type for you.
* alt-shift-m Extract text-selection as a method
* alt-shift-i inline selected method

Running and debugging.

Alt-shift-x is a really handy prefix to run stuff in your current file.

    * alt-shift-x t run unit tests in current file
* alt-shift-x j run main in current file
* alt-shift-x r run on server

There are more. The options are shown to you in the lower-right popup after hitting alt-shift-x.

Alt-shift-x can be switched for alt-shift-d in all the above examples to run in the debugger.

Validation

As of the recent Ganymede release, you can now switch of validation in specified files and folders. I've been waiting for this feature for ages.

    * Go to Project | Properties | Validation
* click on the ... button in the settings column of the validator you want to shut up
* Add a rule to the exclude group

code navigation

    * hold down ctrl to make all variables, methods and classnames hyperlinks to their definitions.
* alt-left to navigate back to where you ctrl-clicked
* alt-right to go "forwards" again

5) Installing the source for the Java libraries in Eclipse

Normally, when you start eclipse, it sets up the JRE that was used to start eclipse. You'll usually want to override this with a JDK so you get the source. To do this:

1. First, make sure you have a JDK installed (and not just a JRE)
2. Start eclipse
3. Go to Window->Preferences->Java->Installed JREs
4. Press Add...
5. Choose "Standard VM" and press "Next..."
6. Press "Directory...", select the JDK installation directory and press "Ok"
7. Press "Finish"
8. Make sure you check the box next to the new JDK
9. Press "Ok" to finish up

This will set up the source properly for you. 

6) Difference between the Eclipse Package Explorer and the Eclipse Project Explorer.

According to the Eclipse help, the Project Explorer provides a hierarchical view of the artifacts in the Workbench, which is customized by the specific configuration of your Workbench.

With only the java developer tools (JDT) installed the Project Explorer nearly looks and behaves for java projects as the Package Explorer (including refactoring and other source code operations in the context menu). But Project Explorer is usable for other languages and project types as well.

Additional plugins contributes "extra information" to the Project Explorer view making it much more "sophisticated". For example if you have the web tools installed and you have a Dynamic Web Project, the Package Explorer shows you additional tree nodes like Deployment Descriptor and JavaScript Resources. You can see (and configure) all available contributions in Project Explorer / Customize View... / Content.

For example using SpringSource Tool Suite 2.1.0 I have additional nodes for web projects, spring beans and web services. Because of this I favor using the Project Explorer.

7) Include Third Party Jars ANT in Eclipse

Always use a nested fileset element inside the classpath element. You can specify specific files or use globbing. It should look something like this:

<classpath id="classpath" description="The default classpath.">
<pathelement path="${classpath}"/>
<fileset dir="lib">
<include name="jaxp.jar"/>
<include name="crimson.jar"/>
<include name="ojdbc14.jar"/>
</fileset>
</classpath>

You can also use the include element to glob, ie

<include name="*.jar/>

So you can include any jar.

8) AutoIndent possible in Eclipse

My clean eclipse install does this by default.

Make sure the file you are editing has the .java file extension. The preference options that control the typing automations are under Java -> Editor -> Typing in the Window -> Preferences menu.

Also, we find that the auto-indenting, and most of the other auto-complete functions of eclipse do not function well if the file I am editing has errors in it, which prevent compilation. Make sure that your curly-braces are matched correctly, this is the main one that I've noticed blocks auto-indent.

Regarding searching through the standard Java libraries, use the Search -> Java. Menu option, and check the JRE libraries checkbox, then search away. You can also use the Hierarchy view to see how the classes relate. Also, in the Package and Project views you can expand the JRE System Library, and then expand rt.jar, which holds pretty much all the standard Java packages.

9) Entering unicode characters in eclipse.

If all else fails, just use a Unicode escape:

String s = "\u1111";

Spares you the hassle of configuring charsets for your source files as well.

10) Debugging NullPointer Exception in Eclipse

Your going in assumption should be the NPE is caused by you, not Android. The NPE may pop at ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268 but that means you passed a null pointer to something and it kept on getting passed around until performLaunchActivity actually tried using it and crashed when it found a null pointer.

If we can see the full LogCat, particularly everything in red in the Eclipse LogCat it would help for debugging. I've turned myself inside out looking for an NPE only for someone else to find a very subtle resource initializing line out of place.

11) Setup eclipse cpp to generate multiple executables

Eclipse is able to generate multiple executables when you write your own makefile. Eclipse is than just performing a make all and puts all binaries in Debug or Release. Then you can run them individually.

Steps to use own makefile: New -> Project -> C++ -> MakeFile project.

12) Changing the index of a TableItem in Eclipse


The following Code can help to change the TableItem index in Eclipse.

public void moveTableItem(Table table, int from, int to) {
TableItem item2Move = table.getItem(from);
TableItem newTableItem = new TableItem(table, SWT.NONE, to);
newTableItem.setText(item2Move.getText());
// You may want to clone the entire item here; and not just the text.

    // Dispose off, the old item.
item2Move.dispose();

}

13) Finding  orphan plugins in eclipse RCPs

Starting point (this applies for Eclipse 3.4 and later, when the P2 repository was introduced, earlier versions store their configuration differently. IIRC you could see all the plugins and features in platform.xml).

Create a new plugin project (New->Other->Plug-in Development->Plug-in Project) with the "Hello World" template then drop this code into the run method of the SampleAction.

Run the plugin as a test Eclipse Application and select Sample Menu->Sample Action, the plugins that don't belong to a feature will be output to the parent workspace's console. When I ran this there were quite a few more than I expected, I've had a few looks through and can't spot the logic error.

Edit, found logic error, was using the wrong array index used in innermost loop. Still not quite right though.

Solution2: Be sure to run the target workspace with all workspace and enabled target plugins enabled, or it will skew your results, obviously. If you install the plugin and dress it up a little bit you won't have this problem.

//get all the plugins that belong to features
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();

Map<Long, IBundleGroup> bundlesMap = new HashMap<Long, IBundleGroup>();

if (providers != null) {
for (int i = 0; i < providers.length; i++) {
IBundleGroup[] bundleGroups = providers[i].getBundleGroups();

        System.out.println("Bundle groups:");
for (int j = 0; j < bundleGroups.length; j++) {
Bundle[] bundles = bundleGroups[j] == null ? new Bundle[0] : bundleGroups[j]
.getBundles();
System.out.println(bundleGroups[j].getIdentifier());
for (int k = 0; k < bundles.length; k++) {
bundlesMap.put(bundles[k].getBundleId(), bundleGroups[j]);
}               
}
}
}

BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();

if(bundleContext instanceof BundleContextImpl) {           
Bundle[] bundles = ((BundleContextImpl)bundleContext).getBundles();

    System.out.println("Orphan Bundles:");
for (int i = 0; i < bundles.length; i++) {
if(!bundlesMap.containsKey(bundles[i].getBundleId())) {
System.out.println(bundles[i].getSymbolicName());
}
}           
}

14) Fixing Eclipse java references database corruption in Eclipse

Follow these steps to fix.

* Export preferences from your current workspace (File->Export->General->Preferences)
* Switch workspaces to a new workspace
* Import preferences into the current workspace
* Import your old project into the new workspace (File->Import->General->Existing Projects into Workspace), choosing "Copy project"

That works for getting the references DB fixed. To get SVN (and presumably CVS) to work again:

* Right click on project, choose Team, and choose "Share project." Choose whichever type of versioning repository you were using and click next. Eclipse should realize that your project was already configured for this and just make you click Finish.

  • Update your sources with the repository.

15) Marking some code that must be removed before production

You could also just define stronger task comment markers: FIXME (high priority) and XXX (normal priority) are standard in Eclipse, and you could define more task tags (Eclipse Properties -> Java -> Compiler -> Task Tags)

If you want to fail your build, you could use the Ant (1.7) contains file selector to look for files containing specified text:

<target name="fixmeCheck">
<fail message="Fixmes found">
<condition>
<not>
<resourcecount count="0">
<fileset dir="${pom.build.sourceDirectory}" includes="**/*.java">
<contains text="FIXME" casesensitive="yes"/>
</fileset>
</resourcecount>
</not>
</condition>
</fail>
</target>

<target name="compile" depends="fixmeCheck">

Obviously, change ${pom.build.sourceDirectory} to your source directory, and FIXME to the comment that you want to search for.

16) Creating a separate Folder in the same package…

What you might want to do, if you aren't putting code in that folder, is remove the folder from the build path. Right-click on the offending folder in eclipse and choose 'exclude from build path.'

Or, you may want a different effect:

Right click on your project and choose add new source folder. Then in that folder, add the correct package folder structure.

You can have files in the same package located in different folders. [ECLIPSE]

You can see that I have a scr and a text folder. They are both root level source folders. The code in the conn package of both folders is in the same package.

17) Set the Eclipse date variable format

The ${date} variable could be enhanced to accept an argument (similar to other parameterizations added in 3.3M1), e.g. ${d:date(format)}, where format is a pattern for SimpleDateFormat.

The only alternative would be to modify the class SimpleTemplateVariableResolver (as described in this thread), from the package org.eclipse.jface.text.templates. (You have here an example of such an extension).

This thread mentions the sources where you can find the class.

\eclipse\plugins\org.eclipse.platform.source_3.1.0\src\org.eclipse.text_3.1.0\src.

Example:

public static class Date extends SimpleTemplateVariableResolver {
/**
* Creates a new date variable
*/
public Date() {
super("date", TextTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$ }

protected String resolve(TemplateContext context) {
//return DateFormat.getDateInstance().format(new java.util.Date());
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
return df.format(new java.util.Date()); } }

18) Search and replace on Eclipse

Use $1 instead of \1

For the /g global replace flag, use the Replace All button:

Note: The above is the Find/Replace dialog for a single file, comes up for Ctrl-F

For working across multiple files, default shortcut is Ctrl-H, and the dialogs are a bit different:

19) Creating war files in Eclipse

You can use Ant to set up, compile, WAR, and deploy your solution.

<target name="default" depends="setup,compile,buildwar,deploy"></target>

You can then execute one click in Eclipse to run that Ant target. Here are examples of each of the steps:

Preconditions

We'll assume that you have your code organized like:

* ${basedir}/src: Java files, properties, XML config files
* ${basedir}/web: Your JSP files
* ${basedir}/web/lib: Any JARs required at runtime
* ${basedir}/web/META-INF: Your manifest
* ${basedir}/web/WEB-INF: Your web.xml files

Set up

Define a setup task that creates the distribution directory and copies any artifacts that need to be WARred directly:

<target name="setup">
<mkdir dir="dist" />
<echo>Copying web into dist</echo>
<copydir dest="dist/web" src="web" />
<copydir dest="dist/web/WEB-INF/lib" src="${basedir}/../web/WEB-INF/lib" />
</target>

Compile

Build your Java files into classes and copy over any non-Java artifacts that reside under src but need to be available at runtime (e.g. properties, XML files, etc.):

<target name="compile">
<delete dir="${dist.dir}/web/WEB-INF/classes" />
<mkdir dir="${dist.dir}/web/WEB-INF/classes" />
<javac destdir="${dist.dir}/web/WEB-INF/classes" srcdir="src">
<classpath>
<fileset dir="${basedir}/../web/WEB-INF/lib">
<include name="*" />
</fileset>
</classpath>
</javac>
<copy todir="${dist.dir}/web/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.properties" />
<include name="**/*.xml" />
</fileset>
</copy>
</target>

Build WAR

Create the WAR itself:

<target name="buildwar">
<war basedir="${basedir}/dist/web" destfile="My.war"
webxml="${basedir}/dist/web/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="${basedir}/dist/web/WEB-INF/">
<include name="**/*.jar" />
</webinf>
</war>
</target>

Deploy

Finally, you can set up a task to deploy the WAR directly into your Tomcat deploy location:

<target name="deploy">
<copy file="My.war" todir="${tomcat.deploydir}" />
</target>

Click and go!

Once all this is set up, simply launching the default target from Eclipse will compile, WAR, and deploy your solution.

The advantage of this approach is that it will work outside Eclipse as well as within Eclipse and can be used to easily share your deployment strategy (e.g. via source control) with other developers who are also working on your project.

20) Setup main function in eclipse makefile project

Place the following in the file Makefile at the project root

 

CXXFLAGS= -g -O0
CXX=g++

all: bin bin/myprog

bin/myprog: bin/startup.o
$(CXX) -o bin/myprog bin/startup.o

bin/startup.o: src/startup.cpp
$(CXX) $(CXXFLAGS) -o bin/startup.o -c src/startup.cpp

bin:
mkdir bin

clean:
rm bin/startup.o
rm bin/myprog

21) Adding undo / redo buttons to toolbar in Eclipse

One way is to use custom plugin. In fact, such custom plugin doesn't need to do anything, only declare new toolbar contribution using existing undo/redo commands.

I've built such plugin for you: http://www.foglyn.com/misc/undoredo_1.0.0.jar. There is absolutely no code, only plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="undoredo.toolbar">
<command
commandId="org.eclipse.ui.edit.undo"
id="undoredo.undo"
style="push">
</command>
<command
commandId="org.eclipse.ui.edit.redo"
id="undoredo.redo"
style="push">
</command>
</toolbar>
</menuContribution>
</extension>

</plugin>

And MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Undoredo
Bundle-SymbolicName: undoredo;singleton:=true
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.ui

You can download it, and drop into your 'dropins' directory of Eclipse, restart, and you'll see Undo/Redo buttons on your toolbar.

Works for me in Eclipse 3.4 and Eclipse 3.5M7.

22) Creating dynamically loaded Linux libraries using Eclipse

In Linux, DLL's equivalents are (kind of anyway) shared objects (.so).

You need to do something like this:

$ g++ -c -fPIC libfile1.cpp
$ g++ -c -fPIC libfile2.cpp
$ g++ -shared -o libyourlib.so libfile1.o libfile2.o

Take a look at some open source C++ library projects for more information. GTKMM is one of them.

Of course, instead of compiling everything manually it's highly recommended to use a make file or an IDE (such as Eclipse with CDT or KDevelop or {pick your favorite here}) that will create one for you behind the scenes.

23) Default eclipse working directory in Eclipse

One thing you can do is set up one launch configuration and then right-click it and choose "duplicate". This will keep all the arguments.

Not perfect, but AFAIK there is no way to change the default working dir, though.

You can also set the dir you want as a string substitution (Window->Preferences->Run/Debug->String Substitution) and then use that variable in each run config - you'll still have to set it but instead of picking the dir each time you just choose the variable.

24) Opening a view after launching in eclipse

Try wrapping your call like this;

Display.getDefault().asyncExec(new Runnable() {
public void run() {
// Your code goes here
}
});

This will put it on the Display thread and should fix the errors your seeing.

25) Eclipse to show .* files

In the package explorer, in the upper right corner of the view, there is a little down arrow. Tool tip will say view menu.

Click that, Select Filters. uncheck .* resources.

So Package Explorer -> View Menu -> Filters -> uncheck .* resources.

26) Memory leak in Eclipse RCP applications

You might want try the Memory Leak Detector that comes with JRockit Mission Control together with Eclipse MAT. It's a powerful combination. Both tools are free to use for development.

With JRockit Mission Control you can inspect the heap online and see the exact number objects of a certain type that are live, without the need to take time consuming snapshots. You can directly see if you got an Editor, View or listener object left on the heap after you closed the View/Editor. It's usually a framework listener that holds on to your view/editor. Remember, you must go to Windows->Preferences->Memory Leak Detector->Trend and set Lowest Heap Usage to report to 0.0 to se all object instances. 

With MAT you can then use the shortest path to thread root to find the chain that is holding on to the leaking object. See below

Modify your code and verify with the Memory Leak Detector that the object is garbage collected when you close the editor/view.

27) Modify/view static variables while debugging in Eclipse

In the Debug Variables view there is an arrow button in the right of the view. The tooltip of this button is "Menu". When you click this button a drop down menu is shown where you can select

"Java" -> "Show static variables"

28) I/O redirection in eclipse

To truly redirect both, the simplest way is still to define your program as an external script

 "java %1 %2 %3 %4 < %5 > %6"

(adapt the number of parameters to your particular program)

In the Run menu, click 'External Tools.../Open External Tools Dialog" and define an external launch configuration in which you will specify both the arguments and the input and output file.

It is not an ideal solution though, as you cannot debug directly your code (with a "debug" launcher configuration).
Instead you have to remote debug it (add '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000' in your generic Java launcher script)

Once you have launched your external tool, launch a remote debug session through the "debug launcher 'Remote Java Application'" section:

29) Adding a whole repository for all projects to use in Eclipse

    * create a 'User Library' (Java/Build Path/User Libraries) with all your class files and add it to every project you need it
* modify your the (Installed) JRE Settings (Java/Installed JRE) for your used JRE Environment. just press edit and add your jars.

Personally I would recommend the usage of 'User Libraries' or the already suggested solution via variables.

30) How to get JavaDoc for SWT and JFace in Eclipse?

I assume you've downloaded the jars yourself and referenced them in your project. If so, you can right click the jar in the project explorer (in the 'Referenced Libraries' node) and click 'Properties'. The window that appears you can define the location of the jar's JavaDoc and source, if you have those available.

You can also reach this by clicking Project > Properties > Java Build Path > Libraries and expanding the node for the jar to which you want to add javadoc/source.

Also worth mentioning that if you use Maven (http://maven.apache.org/) for building your project, it's dependency management system will take care of finding sources and javadocs for you. But that's a different topic entirely. Also might be worth looking at Ivy (http://ant.apache.org/ivy/) - similar dependency management system, but can be used without selling your soul to Maven.

31) Java: export to an .jar file in eclipse

No need for external plugins. In the Export JAR dialog, make sure you select all the necessary resources you want to export. By default, there should be no problem exporting other resource files as well (pictures, configuration files, etc...), see screenshot below.

32) Install javax and apache plugins in eclipse.

You just need to add the required libraries to your build path. You won't find those in update sites.

Here's what you need to do:

   1. Locate and download the required JARs. You can use a service like FindJar.com to search for those JARs. Apache JARs are usually available from apache.org.
2. Put the JARs in a folder called lib in your project.
3. Refresh the project in Eclipse (F5 or right-click and "Refresh"), the lib folder with the JARs should appear in your project explorer.
4. Add them to the build path - in the Eclipse project explorer, right-click the JARs and select "Add to build path"

33) Change the color of Eclipse RCP view title bar.

You can change the color with this is possible with the org.eclipse.ui.themes Extension-Point.

Here's an example snippet

   <extension
point="org.eclipse.ui.themes">
<theme
id="de.spiritlink.custom.ui.theme"
name="Custom Theme">
<colorOverride
id="org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"
value="255,0,0">
</colorOverride>
<colorOverride
id="org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"
value="0,255,0">
</colorOverride>
</theme>
</extension>

Setting the theme programmatically with IThemeManager, which is an object that contains references to usable ITheme objects and maintains a reference to the currently active theme. This theme will be used by the workbench to decorate tab folders and other controls where possible:

PlatformUI.getWorkbench().getThemeManager().setCurrentTheme("myThemeID");

How can I include .class files in my project in Eclipse? (Java)

You can add a directory containing the class files to the Eclipse project, only if it is inside one of your Eclipse projects, either in a generated directory or in one you have created.

This can be done by adding the class folder to the Java build path of the application. You can set this in the Project properties, by visiting Java Build Path -> Libraries -> Add Class Folder. Keep in mind, that you will have to specify the root folder containing the class files in their packages.

Therefore, if you wish to have the compiler access com.stackoverflow.Example.class present in the classes directory under project A (but not in the build path of project A), then you should add 'classes' as a class folder, and not classes/com/stackoverflow as a class folder.

Debug Pylons application through Eclipse

Create a new launch configuration (Python Run)

Main tab

Use paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory)

Don't forget to add the root folder of your application in the PYTHONPATH zone

Arguments set the base directory to the root folder also.

As Program Arguments use "serve development.ini" (or whatever you use to debug your app")

Common Tab

Check allocate console and launch in background

For more tips you can reach the author from the following email-id.
KDatta23@gmail.com








}