Monday, December 1, 2014

How to solve Error parsing XML: unbound prefix for com.facebook.widget.ProfilePictureView in Android

Hey people,

these days I'm working with Android Facebook SDK, a field that I'm pretty new, too, so I considered sharing a little experience that I recently faced.

Supposing that you want to connect your app to Facebook, you obviously need a login button, first of all., so your xml code should look like this:



Ok, nothing special, but if you want to add the user's profile picture too, see what happens:

Error parsing XML


And this is what the console logs:

C:\Workspaces\eclipse_luna\FacebookApp\res\layout\activity_main.xml:14: error: Error parsing XML: unbound prefix

So, if you 've already read that, but didn't find a solution, here is the single line that you need to your namespaces:
xmlns:facebook="http://schemas.android.com/apk/res-auto"

Now, everything seems to work, without any errors:


Cheers!

Sunday, November 30, 2014

How to install Perl and cURL on Windows

Hello!

Perhaps you 'll never need Perl, but when you are about to do it, you obviously don't want to mess with cygwin and stuff like that.

I actually found a simple solution to get it up and running in about 5 minutes, together with cURL installation, without configuring anything on your environment, but only running the .msi installers.

If you don't actually know it, Strawberry Perl is the most stable version for Windows, so:


  • Visit Strawberry Perl site.
  • Download the version that matches your system (I'm on a 64-bit machine):

  • Run the installer.

The installer automatically places the Perl directory under the correspong Program Files folder (so, for me, it is under "Program Files", but if you selected the 32-bit version of it, it should place it under "Program Files (x86)".

It also adds the perl executables to your system path, by default.

  • Validate the successful installation of Perl, to your system: 

I suppose the only reason for someone to start using Perl in 2014, is related to web technology, i.e transfering data by using different protocols. An easy way to do that, is by using the cURL tool.

While on my investigation to do this without having to use cygwin or my cmd, I found this site, that also provides an .msi installer in a reliable way, like the one we 've used for Perl (the highlighted version is what worked for me):


So, when the installation is finished, you just have to validate that you 're good to go:


Cheers!

Tuesday, October 28, 2014

How to install MongoDB on Windows

After all, a new post!

The other day, I found myself messing around with MongoDB and I was wondering if I could find some time to write a blog post about it; this one isn't anything  special, but I hope it 'll be the start for a bunch of MongoDB tutorials.

The goal of this post is not to demonstrate the functionality/usage/advantages of MongoDB, so, if you need further assistance, you should refer to the official docs.

You can download both server and client for MongoDB from a single .msi file, from the official downloads page. For my case, I chose the 64-bit version of it:


The installer, by default creates a new directory named MongoDB [version] Standard  under the Program Files directory.

As with MySQL, we first have to start the server application; what we 're looking for is a similar to mysqld.exe executable; the location where we should search for it is pretty obvious, under the \bin subdirectory of the fore-mentioned, newly created directory:


After ensuring the existence of it, you can open a command prompt and after locating the working directory of it to the specified path of mongod.exe, start the service:


I marked with pink dots the two main points of the service start:

  • MongoDB runs at port 27017.
  • There are initially 0 active connections.
Let's connect from a client to it:


As you noticed, too, it auto-connects to a database, named test.
I saw a blue indicator filling my left tab (this is my MongoDB started server), after giving the connection command, so let's see what's new:



Ok, connection was successful!

Now, let's go back to our client and see a single object, that exists in the things collection of test database:




And that was it!
For more details about the last command and its results, stay tunned!

Saturday, August 9, 2014

How to create a working set in Eclipse

So, the amount of imported projects that your eclipse IDE has, seems like turning it into a mess?

Have you already thought of a way to separating them into smaller sets, according to the project/concept that they rely on?

Here is an example of mine, when I wanted to split some of the projects, regarding the JCG community.

1) Near the "Package Explorer", click the drowdown button (the corresponding tooltip names it "View Menu") :


2) From the options provided, click on Select Working Set:


3) Select th Java as the Working set type:


4) Create a new Window Working Set:


5) Give a name to the working set and after selecting the projects that you want to be added to it, click "Finish":


6) After creating the working set, a window pops up, prompting you to declare the working sets that you currently want to work with, so just check them and click "OK":


7) Obviously, now the Package Explorer is set up according to the projects included in the selected working set:

Alternative Paths
  • You can edit the existing projects of a working set by selecting Edit Active Working Set from the "View Menu" dropdown (this option is visible if there is at least one working set in your Eclipse environment).
  • You can deselect a working set in order to get the Package Explorer to its initial state (displaying all existing projects in the workspace that Eclipse runs on) by clicking Deselect Working Set from the "View Menu" dropdown.


Sunday, July 27, 2014

How to setup Mongoose Web Server: a really lightweight one

Developing web applications always requires a web infrastructure, in order to test them, before getting them into production, but many times, we just want our app to consume a web service (that is, to be working as a client), so the requirements for a web server are very lightweight.

If we aren't familiar with web servers and similar stuff and we just want to quickly setup a server in order to test our web app's functionality, Mongoose is here to give the answer, as it's the most easy to setup and use web server in the market.

To quickly download and set it up, come along:

  1. Visit this link and download the Windows Executable that corresponds to free edition:
  2. Add the directory path of the executable in the environmental variable called "Path" (if you need more assistance getting over this, please refer here); for example, my executable's absolute path is C:\Thodoris\Servers\mongoose-5.3.5\bin\mongoose.exe, so I should add C:\Thodoris\Servers\mongoose-5.3.5\bin in my "Path".
Good to go, just navigate to the working directory (folder) of your project, through command line and type mongoose; this produces a web server that runs and serves that folder as the web root.

Regarding the simple web apps that I'm developing over time for educational purposes,  I have set a global "mongoose" folder, where I place all the required assets. It lies under C:\Thodoris\Workspaces\mongoose directory andhere is a dummy view of it:


So, let me run my server:


After successful execution of the command, server root in the default browser:

And it's not over. If you 're aware of host's IP address, you can ping it from any other device, connected in your LAN!

Cheers!

Tuesday, July 22, 2014

How to convert tabs to spaces in Notepad++

So, the very first project that I was exposed on, as a professional, included, among others, YAML and as you obviously know YAML has a strict syntax.

Notepad++ is till now, my favourite editor, but it comes without something that is very useful to the case that we 're investigating today, a "Tabs to Spaces" plugin/feature (I found that the one provided under the Edit -> Blank Operations menu was missing basic functionality). 

There is a solution, though, come along!

  • First of all, we have to download the plugin.
  • We then copy the CLRTabsToSpaces.dll from the .zip file that we just downloaded into \path\to\Notepad++\installation\plugins folder.
  • If Notepad++ is open, we have to close it and restart it again, in order to let the software track the changes.
  • Navigating to the "Plugins" menu, we should see something like below:


That is, we have set properly our plugin, so to get it working, we just follow the above screenshot, to get the tab characters be converted into spaces.

Note: it's better to edit such code snippets, having enabled the "Show all characters" button: 

And a small example (sample code from here ):

Before applying the plugin.

After applying the plugin.


Cheers!


Wednesday, July 9, 2014

How to solve Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V in Android

So today, while writing an example for the JCG community, I came across the following exception, while trying to add an EditText element to my application:

Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V

Despite the fact that I selected Android 4.4 (API 19) for my application, I noticed that the selected Android API in the Graphical Layout of my XML code was actually wrong:


So, the easy way, I clicked the dropdown to select again my initial option:


Note: the Wear versions don't support EditText elements and that's why we got the exception.
And of course, everything was fine after that:


Cheers!

Thursday, July 3, 2014

How to generate random UUID in Java

Hi there! Generating a random UUID is much more easier than you could ever imagine! I use the following block of code, whenever I'm in a need of more than ten:
for(int i = 0; i < 30; i++) {
   System.out.println(UUID.randomUUID());
}
If things get difficult and time passes, working with UUIDs, you 'll probably get lost, if the way you chose to generate your UUID was "a bunch at a time", like above, so you could either visit a site, like this or modify your program like below:
   System.out.println(UUID.randomUUID());
Cheers!

Monday, June 30, 2014

How to create a MySQL database with default encoding and collation

Hi there, pretty much time since my last post (and I 'll apologise in a future post)!

During the project that I was exposed to, to the company I work for, the last months' google searches resulted finding myself with the difficulty to reach a solution for creating a database with default encoding/character set and collation, so I decided to write this post, when finding some free time.

Assuming that we want to create a MySQL database from command line, with default encoding and collation, the command should look something like this, in a generic format:
CREATE DATABASE [preferred_database_name] DEFAULT CHARACTER SET [preferred_encoding] DEFAULT COLLATE [preferred_collation];

More specifically, if I would like to create a database named test_db, with the default encoding of utf8 and default collation of utf8_general_ci, the generic format, easily converts into:
CREATE DATABASE test_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

Pretty easy, huh?! Have a nice week!

Monday, April 21, 2014

Git: Hot to solve fatal: unable to access [url]

So today, while trying to push the latest commit for my last JSF tutorial here, I got an error like this:

fatal: unable to access 'https://github.com/toubou91/JavaCodeGeeks_examples.git/': SSL read: error:00000000:lib(0):func( 0):reason(0), errno 10054

After a small investigation, I found myself reading this thread but the question persisted, as I knew that I had configured properly both my local repo's .git and git's .config file, so I tried pinging my remote repo from a browser.

I noticed that I was prompted to insert my account's credentials (so the reason was that I have been logged out from my remote repo and the local push couldn't match the destination).

After signing-in again, git push succeeded!

Cheers!

Sunday, April 20, 2014

PanelGrid Example in JSF 2.2

Hi there.

So, yesterday, I had some time to write another small tutorial for the JCG community.

You can find the full tutorial here; I also uploaded the source code to my GitHub account.

Have a nice week!

Wednesday, April 16, 2014

How to avoid console errors in older browsers

    

Sunday, March 9, 2014

How to add a single file to an existed GitHub repository

So today, after finishing the required editing about my forthcoming published tutorial on JCG, I wanted to push the final compressed project in the corresponding GitHub repository.

Here is a full guide of how he do something like this:
  • Firstly, locate Git Shell to the directory of the local repository
  • Ensure that you have the right "version" of the remote repository by pulling it: git pull
  • Add the file that you wish to push: git add [filename]
  • Commit changes (it is recommended to also submit a commit message, something that can be done with the -m parameter): git commit -m "your commit message"
  • Push changes to the remote repository: git push
And here's a full screenshot of my effort - yes, you did make it clear; I made a mistake (tried to push without having my repo pulled first) just to demonstrate how helpful is the error handling provided from the shell.
And a personal statement: Finally, I have to admit that learning Git wasn't a pain at all.




Friday, March 7, 2014

How to fix Java heap space error in Maven

So you want to build a maven project but you 're getting an error like this : java.lang.OutOfMemoryError: PermGen space.

What the output says is that you have to define a MAVEN_OPTS environment variable, where you can place your -Xmx and -XX:MaxPermSize memory parameters.

What are you staring at? Go for it!


  • Right click on My Computer and select Properties
  • Click Advanced System Settings on the left
  • Go to the Advanced tab, click the Environment Variables
  • Create a New user variable, under the name of to MAVEN_OPTS and set the Variable value to what the error specified or whatever you need to get it build successfully.


  • Here's a sample configuration :


    Thursday, March 6, 2014

    JSF projects available on GitHub

    I found myself today having a lot of desire to contribute to community, although I needed a lot of rest, so here is my latest commit to my github account : JSF 2.2 projects .


    I know, all of us would prefer the full sources of it, but keeping in mind my full schedule this period, it's the best I could do.

    How to export Eclipse project as a .zip file

    Hi there!

    After a pretty exhausting day at work, I thought why not updating a little bit my blog with a post that someone could find useful?

    I got inspiration while writing my last tutorial for Java Code Geeks, which I scheduled for tomorrow (and yes, you guessed it right, I'm gonna talk again about a tutorial of mine hah).

    So, most of you that ended up to this post, possibly found yourself in the same position as I did, a long time ago: while working on an eclipse project, you simply thought about zipping the whole project and yes, it would be cool if there was a way to implement it not by hand.

    Here are the steps:


    • Right-click on the project and navigate to Export :


    • Select Archive File and click Next : 


    • Select which folders/files you wish to exclude from the final .zip (I excluded the target folder, as you see), give a name to the compressed file and hit Finish : 


    And a final note : target  folder is what comes out from maven execution, so we obviously don't need it in a .zip file or in a project that we plan to upload to github, for example.

    Hope you found it interesting,
    Cheers!

    Sunday, February 23, 2014

    Multiple Selection ListBox Tutorial in JSF 2.2

    Hi there!

    I know I didn't do what I really promised in my last post, but there's really no time, so today that I found some time for editing, I published my new JSF tutorial.

    It has to do with multiple selection listboxes in JSF 2.2 and you can find the full tutorial under this link.

    Have a nice week everybody, hope to see you soon with better stuff!

    Friday, February 14, 2014

    Just Thoughts

    Hello World!

    It's been a long time, since I uploaded my last post, but I had exams! Finally, I got rid of them yesterday, so I found sometime for myself, too; I decided to watch a movie that would make me think after the end, so I ended up with The Wolf of Wall Street (it's going for Oscar).

    So today, this post, as you already realised, will just express some thoughts.

    The reason that I started with the movie, is that I just wanted to mention that we all make our choices and probably are responsible for them. A simple one, but I believe everyone who saw the movie, will understand.

    The other thing is that I started a new tutorial for the Java Code Geeks community, which will probably be published tomorrow - it has to do about listboxes in JSF 2.0 .

    Finally, I'm planning to upload to my github account -probably tomorrow- 2 examples that deal with simple GUI applications in Visual Basic.NET; it was about a year ago, when a friend of mine asked me for help, in order to implement some programming assignments for a required for his studies course.

    That's all for now, have a nice and proactive day!

    Saturday, February 8, 2014

    New JSF 2.2 Tutorial

    Hello World, exhausting day today; I'm always a night guy and it's only 9:35pm, but I'm saying it, 'cause I found 1 hour after my meal to have my shoulders workout done! I prefer working out late at night, but it was Saturday, so I didn't have many choices.

    Usually, after evening workout, I'm very tired and I can't do anything in the rest of the day, but today, thank God, I achieved concentration. Here's my today's "CheckBox Example with JSF 2.0" published tutorial.

    And a closing tought :
    • I don't know the exact duration of this blog's ugly layout-design, but I really don't have any time; I also want sometime to improve it.
    Have a nice Saturday night.

    Wednesday, February 5, 2014

    New Published JSF 2.0 Tutorial

    Although during exams everything else, is very difficult to deal with, I yesterday decided to take a break from studying, by writing an example about RadioButtons integration with JSF 2.0, for the JCG community. At this point, I'm very happy that this time wasn't wasted from studying, mainly for two reasons:
    1. I got some serious troubleshooting during the tutorial's development, which I'm going to display in a new post, in order to help others that may face same problems, sometime
    2. Despite this wasn't the first time that a product of mine was accepted from the wider community of Java, today I was more like happier, as a Java's twitter account, twitted the fore-mentioned example; a tweet that was favorited from Reza Rahman, a multi-dimensional professional and a Java Evangelist, working for Oracle, a person that I personally admire and respect a lot.
    Obviously, the above two-point-list isn't "catchy" for anyone, but encourages me to continue contributing to the software community.

    Time to study, have a nice evening.

    Thursday, January 30, 2014

    How to remove the border of a JFrame

    Assuming that you 're developing an application, in which the default look-and-feel doesn't match, at all.

    To be more specific, imagine the following example: I sometime wanted to develop a real-time clock JAVA application. It would be a bit ugly for the application's purpose to have the annoying border around its JFrame.

    Indeed, there is a way to implement this: you just need to set the frame's undecorated method to true:   frame.setUndecorated(true);

    Keep in mind that the above code has to be placed before frame's setVisible() method. Otherwise, it's like initializing the frame and then telling it to be undecorated, sth that doesn't make sense. So, you first customise the frame as you wish (undecorization, etc) and then you enable its visibility.

    The full application that supports this post is related here.

    Wednesday, January 29, 2014

    How to solve LF would be replaced by CRLF git

    It's nearly to seven in the morning (new english expressions) and before going to bed, I would like to share this experience, as the most stuff that I found over the net wasn't very impressive to my tired eyes.

    I today started dealing with github and git, although there have been months since I first created an account. 
    So, sometime, while trying to upload some files to a public repository of mine, I got the quoted message, displayed in the title.

    I tried to find a quick solution to stackoverflow, refering to the first hits of google, here and here, but while being in a rush, my eyes caught words like unix, etc., so I tried to found out by myself what was going on, because the exact error message, did also included the filename that was causing the error.

    EDIT: Before continuing reading this, be sure that you tried the following command in the git shell:

    git config core.autocrlf false
    

    Opening the file was like a dream:

    1. What I quickly understood in the fore-mentioned links, was what I exactly seeing in my file.
    2. The little knowledge that I accomplished to acquire through this quick reading, made a light flash in my mind.
    The exact image was sth like this : 
    So, I just had to hit my Backspace button
    and everything got as default; successful push
    to github accomplished!
    If the above wasn't enough and you countinue getting errors, try to open the specified file with Notepad++, go to Edit => EOL Converion => Windows Format.

    Dunno if this really helped you or it made your situation more difficult, but I thought about sharing it, 'cause newbies like me in github may find it useful.

    How to configure Primefaces 5.1 and JSF 2.2 in Eclipse IDE

    Hi there!

    Today I will show you how to configure Primefaces 4.0 with JSF 2.2 in the Eclipse Kepler IDE (v4.3).

    If you don't have any idea of what we 're talking about or it's the first time that you 're facing J2EE, you may find interesting my first two articles about JSF 2.0 and Eclipse integration, in JCG community :
    1. JSF 2.0 Eclipse IDE Support
    2. Hello World Example with JSF 2.0
    Now that you 're enough experienced, let's link Primefaces with JSF and Eclipse, too. There are two main actions that we need to no, in order to implement this:

    We first need to add the following dependency, in the pom.xml file:

    <dependency>
       <groupId>org.primefaces</groupId>
       <artifactId>primefaces</artifactId>
       <version>5.1</version>
    </dependency>
    

    We 're pretty ready! Naaah, don't be in a rush. As you might found out by yourself, Primefaces deals with the visual components of our websites, so obviously, the xhtml reference that we provided (in the fore-mentioned links/articles) isn't enough; we need to add two more references, in order to get the Primefaces up and running:

    <html xmlns="http://www.w3.org/1999/xhtml"    
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:p="http://primefaces.org/ui" >
    

    That was it. You 're ready to start developing your awesome look-and-feel web applications with JSF and Primefaces.

    I also created a simple gist for the purpose of this configuration. 


    Cheers!

    Tuesday, January 28, 2014

    That's my very first post, so...Hello World!

    I won't introduce myself in detail, as you 'll find out many information about me in my social netoworking profiles; the only thing that I would like to express as a first feeling is to just excuse me about whatever you may not like and is related to the current blog's layout and "look & feel" - I'm a newbie blogger, so be patient about it, please!

    I just want to mention, that the purpose of this blog is mostly to share programming and software related information that I find interesting (and to get feedback, of course) ; something tha cannot be done through social networking (except GitHub).

    To sum up, my second post will be related to Primefaces 4.0 + JSF 2.2 configuration in Eclipse Kepler (v4.3).

    So, stay tuned!