Work with Eclipse Kepler - witchi/gallery-remote GitHub Wiki
Install Apache-Ant 1.94 to your local filesystem (binary distribution). Add the Ant Runtime to the Eclipse settings. Go to Window->Preferences->Ant->Runtime. Click on "Ant Home..." and select the directory of the local Ant installation. Click "OK".
In the Package Explorer chose "Import..." from the context menu. Select "Projects from Git". Clone the repository ("Clone URI"). Select as Destination Directory a subdir below your Eclipse workspace (i.e. gallery-remote/src). Import the project as "general project". Change the project name to "gallery-remote". This name will be visible within the Package Explorer. You will see all resources within the Package Explorer as Git project.
Open the Navigator view. Select the file .project within your project. It looks like:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gallery-remote</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
To switch it into a Java project, add some lines to the file:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gallery-remote</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
You will see some red-marked files in the Package Explorer. Go to the local Ant installation and copy the file "ant.jar" from $ANT_HOME/lib into the "lib" folder of the project. Refresh the project tree. Click on the project root node and select Build Path->Configure Build Path from the context menu. Click on the Libraries tab and select "Add JARs...". Add the files
lib/ant.jar
lib/AppleJavaExtensions.jar
lib/junit-4.4.jar
lib/metadata-extractor-2.1.jar
lib/saverbeans-api.jar
from the project (see above). Hold down the CTRL key to select multiple JARs. Select the tab Order and Export and move all added JARs above the JRE System Library. Click "OK". All errors are gone.
Open the Ant View in the menu with Window->Show View->Ant. Select the file "build.xml" in the Package Explorer and drop it in the Ant view. There is a warning (PostChangeLog cannot be found), which you can silently ignore for the moment.
Select the target "compile" in the Ant view and run this target. You get a warning "'includeantruntime' was not set". Open the build file in the editor and go to the target "compile". Set a new parameter for the javac task and change the Java version:
<javac includeantruntime="false" source="1.6" target="1.6" ...
Run the "clean" target from the Ant view. Try to compile the project again. You will get a lot of "unmappable character" errors. All these errors come from the HTTPClient framework, where the author name has a special german character. Open a shell, go to the folder and use sed
to replace the wrong characters:
cd HTTPClient
sed -i 's/\x61\x6C\xE4\x72/\x61\x6C\xEF\xBF\xBD\x72/g' *.java
cd ../com/gallery/GalleryRemote
sed -i 's/\x61\x6F\xFB\x74/\x61\x6F\xC3\xBB\x74/g' PictureSelection.java
cd prefs
sed -i 's/\x61\x6F\xFB\x74/\x61\x6F\xC3\xBB\x74/g' PreferencesDialog.java
Refresh the project tree within the Package Explorer, run the "clean" target from the Ant view. Try to compile the project again. You will get some package errors. Add the file "lib/ant.jar" to the classpath of the javac task.
<classpath>
...
<pathelement location="lib/ant.jar" />
</classpath>
Run the "clean" target from the Ant view. Try to compile the project again. There is still a warning and an error.
class file for com.sun.image.codec.jpeg.JPEGDecodeParam not found
Add a new tag
<compilerarg value="-XDignore.symbol.file"/>
to the javac task (right before the classpath tag). Run the "clean" target from the Ant view. Try to compile the project again. You should be able to compile the project without any warnings nor errors.
Now chose the "Run" target in the Ant view and execute it. The application should start (exceptions are possible in the console view).
To debug your application, we use the "debug" target from the Ant view. Open this target in the editor. Look for the "jvmargs" attribute of the "java" tag. Change the attribute to nested tags:
<java ...>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
...
</java>
Change the value of suspend=n to suspend=y, this will stop the application until the Eclipse IDE has been connected to the remote VM.
Go to the menu and chose Run->Debug Configurations...->Remote Java Application. Create a new one and set the port number to the address above (5005). Click "Apply" and "Close". Set the necessary breakpoints in the application code.
Execute the "debug" target from the Ant view (only run, don't debug it). In the Console view you will see
"Listening for transport dt_socket at address: 5005"
The application has been halted. Select the project root node in the Package Explorer, go to the menu and select Run->Debug Configurations. Execute your remote Java application configuration. It connects to the remote VM (started by Ant). The next time you can use the Debug History to execute the configuration.
The application should run again and stop on the first breakpoint. Eclipse switches to the Debug perspective.