Author Archive


Json REST api Test with Java

Thursday, July 21st, 2016

 

I recently put together this simple program that parses JSONinput from either a file or a url. It showcases the use of REST apis to a read data and store it as a JSON object, JSON array and other Java objects for further manipulation.

It uses the example website: jsonplaceholder.typicode.com/albums and reads the data.

It will also read a local JSON file.  For the program to complete successfully you need to either create a JSON file named  “C:\jasondata2.json” or use any name and change the name inside the program. To easily create a JSON file you can download the data contained in the file url above and save it.

The secret to easily reading a URL and storing it’s contents is really just a few lines.  You want to use a BufferedReader to experience efficient reading of characters, arrays, and lines.

 


 

 

Once you have an entire JSON string (starting with “[” ) you can turn it into a Collection, JSONArray, ArrayList or Map like this:

 

 

Here’s the entire program.

 

 

Transferring to a New Domain Registrar

Thursday, May 26th, 2016

Transferring your domain to a new registrar can be frustrating if you miss any of the necessary steps. Here I will outline steps that should apply to most registrars. I’ve used the same steps with GoDaddy, Name.com and Namesilo.com.  The whole thing can go very quickly – in as little as 10 minutes or so assuming both registrars respond quickly.

  1. Go to the “winning” registrar:
    a) Setup an account (if you haven’t already).
    b) Find and record their recommended name servers.
  2.  Log into the “losing” registrar (the one you’re leaving) and:
    a) Make sure you like the email address that the Registrant, Billing, Technical and Adminstrative email addresses are set to because they’ll need to communicate with one or more of these during your transfer. To be safe, switch them all to your current email address.
    b) Turn off Forwarding (if it’s on)
    c) Turn off Privacy (if it’s on)
    d) Unlock the domain
    e) Ask for a transfer “key” which may be called a key, transfer secret or authorization code. You’ll need this at the winning registrar. The loser provides it to you on their website or emails it to you.
  3. Go back to the winning registrar:
    a) Request the transfer. You’ll input the domain address and the authorization key-code-secret.
  4. Watch your email. The winner will send you an email asking you to verify that you want to transfer in. Watch for this email and verify yes.
  5. Next you need to log back into the losing registrar and ask them to expedite your transfer. GoDaddy has a way to do this online, where Name.com asks you to email their support team. In any case, most of them are very quick to respond because if they aren’t – they are leaving your domain in a dangerous state of no privacy, no forwarding, etc. I’ve seen this happen in a matter of a few minutes after making this request.Here’s the GoDaddy instructions for getting them to accept a transfer out: GoDaddy Accepting-or-declining-a-transfer
    If you’ve chosen a decent registrar, they should have a progress page you can go to to see your progress. They may also email you some kind of confirmation of progress.
  6. After the transfer, go into the settings and remove the old nameservers. Make sure all the dns settings are correct. Reset up your forwarding and privacy settings.

As far as which registrar to choose – I ended up at Namesilo.com because they offer great service, are super inexpensive, and offer free Whois privacy with every domain.  Name.com was also very good – just not as inexpensive. GoDaddy is fine – just very pricey.

In closing, here are some great dns tools you can use to check your domain:
network-tools.com/nslook
www.dnsinspect.com

Eclipse with Java, Maven and Git setup

Friday, January 1st, 2016

It took me awhile to perfect my setting up of Java-based projects in Eclipse that also utilize Maven and Git. I wasn’t sure in which order to do it, and if it should all be done inside Eclipse or not. So I thought I’d share my final process here. My version of Eclipse is Luna, although the general steps should work with other versions as well.

First you need Eclipse set up with the m2e (Maven to Eclipse) plugin. You will also need to install the EGit plugin. You need to have a regular “Workspace” set up, and optionally a Git local respository set up as well (NOT inside the Workspace – should be a separate directory). Or – you can let the EGit plugin create a Git repository for you.

In Eclipse, from the “File” menu, select “New” then “Other”. In the wizard that pops up, open “Maven” then select “Maven Project”. Click “Next”, then select the “Create a simple project” box.

In the next window, for Group Id – put your package name, and for Artifact Id – put your package name. Add a name for the project itself and other items if you like. Click finish.

The new project will be created in your regular workspace. For Git – remember you need to have the EGit Eclipse plugin installed.

To add your project to your Git repo, open up the “Java Browsing” perspective, and right click on the new project you just created. Look for the word “Team” in the menulist that pops up. Select “Team” (in my list it was 8th from the bottom), then “Share Project…”. Follow the prompts from there to use an existing repository or create a new one.

Now you should have a new Java Maven-based project in your Git repository. Notice the pom.xml file that is create. You will have to add your own dependencies to this.

Below is an example of the simple pom.xml file file that is created: