Java: Unsupported major.minor version 51.0

When you get an error:

Unsupported major.minor version X

This means that you are trying to compile your Java program with version lower that the code is written for; for example you develop with Java 1.7, deploy on the server where they have Java 1.6:

Unsupported major.minor version 51.0

The fix is:

  • to change your code to use lower Java, which is sometimes impossible because of 3rd party library that you are using
  • upgrade the other computer to modern Java, which is sometimes impossible because of a brick-head gatekeeper
  • vent on the blog and start cutting out the code 


Java versions:
  • J2SE 8 = 52
  • J2SE 7 = 51 
  • J2SE 6.0 = 50 
  • J2SE 5.0 = 49 
  • JDK 1.4 = 48 
  • JDK 1.3 = 47 
  • JDK 1.2 = 46 
  • JDK 1.1 = 45

If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

Organic Garden



As an Amazon Associate I earn from qualifying purchases.

RoboGuice - Android development made simple and fun



"Simple and Fun!" Now, they make quite a promise!

read up:

https://github.com/roboguice/roboguice/blob/master/README.md

https://github.com/roboguice/roboguice/wiki

Maven repo:


org.roboguice
roboguice
3.0.1


OK, so most of all RoboGuice is about DEPENDENCY INJECTION



Examples:


@InjectView(R.id.label)
TextView label;

@InjectResource(R.string.app_name) // strings, drawables
String applicationName;

@Inject // system service
LayoutInflater layoutInflater;

@Inject
LocationManager locationManager;

@Inject // POJO
Book book;


Creating Activities



public class FightForcesOfEvilActivity extends RoboActivity {

@InjectView(R.id.expletive) 
TextView expletiveText;

Creating Android Modules


public class MyModule extends AbstractModule {
@Override
protected void configure() { }



AsynchTask 


public static class AsyncPunch extends RoboAsyncTask {

// Astroboy is a @Singleton public class Astroboy {
@Inject Astroboy astroboy;

// new instance of java.util.Random, since we haven't specified any binding instructions
@Inject Random random;


If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

Donate Bitcoins



As an Amazon Associate I earn from qualifying purchases.

SHH key

$ git clone git@github.com:roboguice/roboguice.git
Cloning into 'roboguice'...

Permission denied (publickey).


$ ls -al ~/.ssh
total 120
-rw-------   1 uki  staff   1675 Oct 31  2012 id_rsa


COPY YOUR PUBLIC KEY to clipboard

$ pbcopy < ~/.ssh/id_rsa.pub 


PASTE your SSH key exactly as copied (i.e. in GitHub settings)
https://github.com/settings/ssh


$ git clone git@github.com:roboguice/roboguice.git roboguice
Cloning into 'roboguice'...
remote: Counting objects: 18463, done.

Receiving objects:  15%

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    MacBook Pro (late 2011) graphics crashing

    With the update to Yosemite (maybe unrelated) my Mac started to crash, at first it was rare, but right now it is consistent, the common situations when it is crashing:


    • connecting external monitor via HDMI
    • connecting external monitor via VGA
    • screen sharing using JoinMe 
    • bad days in general
    The MacBook Pro (starting with early 2011) have 2 GPU (graphic cards), one integrated, low power, and one additional (discrete) that is used for high power situations.

    I installed the utility called gfxCardStatus that allows me to switch between integrated and discrete graphic cards.

    From their website:

    gfxCardStatus v2.3 and above actively prevents you from switching to Integrated Only mode when any apps are in the Dependencies list (or if you have an external display plugged in). This is because if you were to do this, your discrete GPU would actually stay powered on, even though you've switched to the integrated GPU.

    So I guess no more external display for me until Apple fixes the problem, or I but new MacBook Pro (hopefully with touch screen this time).




    https://developer.apple.com/library/mac/qa/qa1734/_index.html



    Reseting System Management Controller (SMC)

    https://support.apple.com/en-us/HT201295

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Spartan Race prep run

    Run with obstacles.


    As an Amazon Associate I earn from qualifying purchases.

    2015 Spartan Race: training day 1

    I signed up for Spartan, 
    if you want run together, or cheer and take photos, 
    I created a team: "Valeria Warriors" to honor our late grandma who brought this family together.

    Seattle, WA, Saturday 11:15AM-4PM, run start time 1PM (IMPORTANT)
    http://www.spartan.com/en/race/detail/878/overview

    weight: 185 lbs (of flab)

    I might consider Wisconsin Tough Mudder, too:
    https://toughmudder.com/events/2015-wisconsin


    Previous run photo:




    As an Amazon Associate I earn from qualifying purchases.

    Java: Closable

    When working with multiple resources that need to be closed after we are done using, I particularly like the approach of using Closable Interface:


    try {
    // open input streams and use them
    }
    catch (IOException e) {
    e.printStackTrace();
    }
    finally {
    attemptClose(inputSteamA);
    attemptClose(
    inputSteamB);
    }



    private void attemptClose(Closeable object) {
    if (object != null) {
    try {
    object.close();
    }
    catch (IOException ignore) {
    }
    }
    }




    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Apple Photos opening every time phone USB is connected

    I work developing Android so I plug and unplug different devices all day long. Apple Mac Photos app is opening every time phone USB is connected, which is frustrating and sometimes out of place at work.

    To turn off that behavior next time the Photos app opens UNSELECT THIS CHECKBOX:

    "Open Photos for this device"


    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Android: TextView in ScrollView continous scrolling

    Sometimes when continuously outputting text to TextView, you would like it to scroll down:



    textView.addTextChangedListener(new TextWatcher() {
    @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    @Override public void onTextChanged(CharSequence s, int start, int before, int count) {
    // scroll down whenever log text updated to display latest info on the screen  
            
            scrollView.post(new Runnable() {
    @Override public void run() {
    scrollView.fullScroll(ScrollView.FOCUS_DOWN);
    }
    });
    }

    @Override public void afterTextChanged(Editable s) {
    }
    });

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Android: AsyncTask delegate

    Let say we have an Activity that wants to receive a messages from AsyncTask.


    We create an Interface
    AsyncResponse
    public interface AsyncResponse {
    void publishLog(String logContent);
    }
    We create our AsyncTask:

    public class FileReaderTask 
     extends AsyncTask < Void, Void, List < AbstractX > > {
    // delegate should be set in the Activity   
    public AsyncResponse delegate = null;
    String xyz = "";
    // ...
    @Overrideprotected void onPreExecute() {
    delegate.publishLog(xyz);
    }
    @Overrideprotected void onPostExecute(List x) {
    ...
    delegate.publishLog(xyz);
    }
    }

    Now we can tie together the AsyncTask and Activity:

    public class FileReaderActivity extends Activity implements AsyncResponse {

    private static final String TAG =
    FileReaderActivity.class.getCanonicalName();
    FileReaderTask asyncTask = new FileReaderTask();

    private TextView logText;

    /** * Called when the activity is first created. */  

     @Override   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.
    main);
    logText = (TextView) findViewById(R.id.logText);

    // tell Async Task that this Activity will listen  

    asyncTask.delegate = this;
    asyncTask.execute();

    }

    /** * This method will receive log from Async Task. * @param logContent */  

    @Override   public void publishLog(String logContent) {
    logText.append(logContent);
    }

    }

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Android: finding SD Card

    Since the implementation of SD card is different on various devices use following method:


    private static final String SDCARDFILE 
    Environment.getExternalStorageDirectory() 
    + "/somefolder/somefile.ext";

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    git: updating all repos using Bash

    I have a lot (hundreds) of repositories I want to keep updated on daily basis, here is a handy script I use:


    # saving current working directory
    cwd=$(pwd)

    echo "reading each repo directory in $cwd"
    for repo in *
    do
    echo '#################################################'
    # change to give repo directory
    cd $repo
    # print repo url
        git config --get remote.origin.url
        git fetch
        git status
        # go back to directory you started with
        cd $cwd
    done
    }

    If you like this post, please give me your 2 cents ($0.02 litterally) to show token of appreciation and encourage me to write more:

    Donate Bitcoins



    As an Amazon Associate I earn from qualifying purchases.

    Toxic woods

    http://www.wood-database.com/wood-articles/wood-allergies-and-toxicity/


    As an Amazon Associate I earn from qualifying purchases.

    8000 grit conditioning whetstone

    This Nagura stone is very small, I will be using it to condition other sharpening whetstones.

    Instructions:

    使用
    方法双方共に水をたっぷりつけて名倉砥石で軽く円を画く様に砥面を, まんべんにこすりすぐ泥が出ますのでそのまま御使用下さい。


    As an Amazon Associate I earn from qualifying purchases.

    Android Studio Canary

    In case you feel adventurous you can try hottest builds from Canary releases:

    http://tools.android.com/download/studio/canary

    Why would you wan to do that?
    For example Android Studio 1.3 (2 days old) has support for NDK.


    As an Amazon Associate I earn from qualifying purchases.

    Wooden sawhorses

    No nails, no glue, beautiful.

    https://youtu.be/nsHpJnYInDo



    As an Amazon Associate I earn from qualifying purchases.

    ATAP

    Forget the Google I/O keynote presentation, this is the real "state of the art" of 2015





    As an Amazon Associate I earn from qualifying purchases.

    My favorite quotations..


    “A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

    "We are but habits and memories we chose to carry along." ~ Uki D. Lucas


    Popular Recent Articles