Packaging a Property File in a Maven Project

When working with a Maven project, property (e.g. config.properties) files are not copied to the build as a default. The easiest way to have them appear in the final jar is to put them in ${basedir}/src/main/resources.

As a result your property file will be copied at the root of your packaged jar.

Manually Add a Jar to a Maven Repository

Use this command to manually add a Jar to a Maven Repository
mvn install:install-file -DgroupId=javax.comm -DartifactId=comm -Dversion=3.0 -Dpackaging=jar -Dfile=/home/misterdom/Documents/3_Software_Projects/WebPlogg/commapi/comm.jar

Removing Latex Tags in a Word Document

We can use the regexp feature of the find/replace tool in Word.

Search for:

\\code\{(*)\}

Where:

  • \ is the escape char (thus the \\ for detecting a Latex tag)
  • * means “everything”
  • ( ) creates a logical entity that you can re-use in the replace field.

and replace by:

\1

which refers to the entity we created by using ().


More info on this doc

Removing a Service from Init.d in Linux

Use this command:

sudo update-rc.d -f SERVICE_NAME remove

where SERVICE_NAME is the name of the service to remove, e.g. vsftpd.

More info on the topic: http://www.unixtutorial.org/2009/01/disable-service-startup-in-ubuntu/

Changing the Default Java Vendor (or Version) in Ubuntu

Run sudo update-java-alternatives -l to see the current configuration and possibilities.

Run sudo update-java-alternatives -s XXXX to set the XXX java version as default.
For Sun Java 6 this would be sudo update-java-alternatives -s java-6-sun

Run java -version to ensure that the correct version is being called.

Source: https://help.ubuntu.com/community/Java

Delete all the SVN Folders in a Directory

find . -name ".svn" -exec rm -rf {} \;

Browse to URI (or URL) in the Default Browser Directly From Java


if (Desktop.isDesktopSupported()) {
Desktop dt = Desktop.getDesktop();
if (dt.isSupported(Desktop.Action.BROWSE)) {
dt.browse(new URI("http://localhost:8182/EnergieVisible"));
}
}

From Java 1.6.

Doing PUT DELETE and Other Niceties with GWT

You probably are REST lovers like I personally am.

Thus you were probably quite frustrated when seeing that a GWT (Google Web Toolkit) client cannot send other requests than POST or GET.
Well here is the solution:

public class RequestBuilderForAnyHTTPMethodTypeExample extends RequestBuilder {

/**
* Constructor that allows a developer to override the HTTP method
* restrictions imposed by the RequestBuilder class. Note if you override the
* RequestBuilder's HTTP method restrictions in this manner, your application
* may not work correctly on Safari browsers.
*
* @param httpMethod any non-null, non-empty string is considered valid
* @param url any non-null, non-empty string is considered valid
*
* @throws IllegalArgumentException if httpMethod or url are empty
* @throws NullPointerException if httpMethod or url are null
*/
public RequestBuilderForAnyHTTPMethodTypeExample(String httpMethod, String url) {
super(httpMethod, url);
}

i.e. simply subclass the RequestBuilder

Source: (see the bottom of the page).

Distributing a Visual Studio C++ Exe That Does not Need the Windows .NET Framework

If like me you export your Visual Studio (2008) .NET C++ project as an EXE, copy it on another machine and get: “This application has failed to start because the application configuration is incorrect”. Then it might be because the target machine is actually missing the Microsoft .NET Framework.

Since I did not really felt like asking all the future users of my app to install the .NET framework, I started looking for a way of embedding these libs in my final app.

While it is apparently not possible to do so without requiring a special (commercial) tool, there is a workaround that worked for me. By forcing the C/C++ to by statically linked the framework functions actually are embedded into the EXE (which, btw, gets much bigger then).

To do so (in Visual Studio .NET 2008 C/C++, Express) do:
Property Page -> Configuration Properties -> C/C++ -> Code Generation then “Runtime Library” should be set to an “non-dll” option such as Multi-threaded (for the release target) or Multi-threaded Debug (to debug your app).

Here we go!

Sources:
http://stackoverflow.com/questions/271290/can-visual-studio-2008-standard-create-a-single-exe-that-does-not-require-net-fr

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/36971526-95f3-4a9f-a601-1843c86332c1

JSON and the Quoted Strings

“Bug” number two for today is a little more tricky.

I was retrieving a JSON object in the GWT (Google Web Toolkit) and putting its Java representation in a HashMap. The only problem is that I could never find it again by referring to its key which I also extracted from JSON object. Here is why:

currentCons.get("URI").isString().toString()

Is actually not returning the String representation of a JSONString object but the quoted representation of that String: e.g. “key” and not key. It was in the API but it took me a while to figure it out…

The solution is:

currentCons.get("URI").isString().stringValue();

Which gets what I wanted, i.e. the String representation without the quotes.

←Older