Wednesday, November 09, 2011

Maven + Subversion Enabled Eclipse Java Project

Updated - Apr 2013
What I want for my Eclipse projects is to be Java projects, allow content revisions with Subversion and be managed by Maven.

This is what I need to do.

Eclipse version: Eclipse Juno
Subversion plugin: Subversive
Maven plugin: m2eclipse (m2e)

Support for Subversion and Maven is now integrated into Eclipse.
  1. Choose Help --> Install new software --> Work with: Juno - http://download.eclipse.org/releases/juno.
  2. Expand collaboration and check the m2eclipse and Subversive packages. Install all required components.
  3.  Add the Polarion update site: http://community.polarion.com/projects/subversive/download/eclipse/2.0/juno-site/ (see step 1 for details) and install the Subversive SVN Connectors and a connector of your choice (I use SVNKit 1.7.4)
  1. Create a new project (Checkout Maven projects from SCM). Choose svn as SCM URL and type the URL. If svn does not appear in the list, check the global configuration under Window --> Preferences --> Team --> SVN --> SVN Connector. The connector you just installed must appear on that list.
  2. Once the project has been created, you might have a Java-Maven project only. If that's the case, to connect it to the SVN repository, right click on the project's name, choose Team --> Share --> SVN and follow the instructions to conncet your project to the SVN source.
Now you have a Java project checked out from a Subversion repository which uses a Maven repository to manage its library dependencies.
You can further configure Maven under Window --> Preferences --> Maven. In particular you can add an external Maven installation and change the location of the repository which defaults to the user's personal repository and not the global one.

Monday, October 24, 2011

Liferay: Error Registering Portlets

I got a problem when trying to undeploy a portlet on Liferay the standard way: removing the unzipped WAR in Tomcat's webapps/ dir and the cached information.

08:48:56,725 ERROR [HotDeployUtil:112] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for MyPortlet

It seemd like the portlet was somehow still in the page for Liferay and the message saying the portlet needed to be removed from the page did not show any buttons to do that. After a while I didn't have the message anymore but only an error page.

Some googling brought me on a page in the Liferay forum where they suggested to remove the portlet-api-2.0.jar from the lib/ directory of the WAR and redeploy it:

> zip -d MyPortlet.war /WEB-INF/lib/portlet-api-2.0.jar

It actually worked. Don't ask me why.

Monday, August 08, 2011

Batch Resize on Linux

Install imagemagick.
Now you can use mogrify.
Example: to resize to half the original size all the JPGs in a directory (keeping the aspect ratio of course):

> mogrify -resize 50% *.jpg

More here.

Eclipse Startup - Crash on Fedora 15

For some obscure reason, the Fedora 15-packaged Eclipse doesn't include JSP syntax highlighting and I could find no easy way to add it (conflicting dependencies prevent that). So I resorted to the original TAR-GZ distribution. The problem there is with the OpenJDK. My Eclipse simply crashes on startup.
What you need to do is tell Eclipse to use Sun's JDK.
Open the eclipse.ini and add the path to the Java executable:

-vm
/opt/java/jdk1.6.0/bin/java

right before the -vmargs option.
More here.

[UPDATE] - Oh, the reason for the crash is not openJDK. It's a bug in Fedora. To circumvent it do the following:
  1. In Gnome3 the webkit library name changed to libwebkitgtk so you need to create one missing symbolic link: ln -s /usr/lib/libwebkitgtk-1.0.so.0 /usr/lib/libwebkit-1.0.so.2
  2. Add -Dorg.eclipse.swt.browser.UseWebKitGTK=true to the -vmargs options in eclipse.ini
More here.

Friday, July 01, 2011

Extracting Audio from Video or Stream

From AVI or other video formats:
> ffmpeg -i file_name.avi -ab 128 -ar 44100 file_name.mp3

From an online stream:
> ffmpeg -i URL_address -ab 128 -ar 44100 file_name.mp3

> man ffmpeg

Wednesday, June 15, 2011

Fedora 15: Old and New Alt-Tab Behavior

As of Fedora 14 (Gnome 2.32) the behavior of Alt-Tab was to cycle through all the windows of all the open applications in a virtual workspace.
Gnome 3 shipping with Fedora 15 behaves differently and probably more efficiently (time will tell.)

Alt-Tab now cycles through all open applications in all virtual workspaces. All the windows of an application are shown when that application is the selected one. You can move the mouse over one window and select it but you can't just use the keyboard to do that.

If you want to cycle through all the windows of the active (selected) application you need to use Alt-~ (or the button above Tab.)

Fedora 15: Add Back Shutdown Option

Gnome 3 by default won't show the shutdown button. To see it click on your name on the top bar and press Alt. The Suspend option will turn into Power off.
If you don't want to perform this extra step (updated after kind comment):
  1. Install: yum install gnome-shell-extensions-alternative-status-menu.
  2. Type Alt-F2 then gnome-tweak-tool
  3. Go to Shell Extensions --> Alternative Status Menu Extension and switch it to on
  4. Type Alt-F2 then r and enter (reloads the Gnome shell.)
  5. You're set! You have gained the Hibernate and Power off options now.

Fedora 15: Add Back Window Buttons


UPDATED on May 9, 2020

Gnome 3 default behavior suppresses all window buttons but the Close. If you want them back:

> gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"

or use: gnome-tweak-tool.

References:
  1. https://askubuntu.com/questions/651347/how-to-bring-back-minimize-and-maximize-buttons-in-gnome-3