Tuesday, May 12, 2020

Using Github with Eclipse

I am using eGit to try this out.

In Eclipse-> Help -> Install New Software -> Work with:
http://download.eclipse.org/egit/updates

Useful video to get started:
https://www.youtube.com/watch?v=ptK9-CNms98

And how to configure projects to push to Github:
https://www.youtube.com/watch?v=LPT7v69guVY
1. How to create github repository 2. How to clone repository in eclipse 3. How to add eclipse project to github repository 4. How to commit, push and pull the changes

Basically:
Step 1 : Create GitHub account and SignIn Step 2 : Start a Project = Create a repository Step 3 : Start Eclipse Step 4 : Goto Perspective - Git Repositories and click on Add Git Repo Step 5 : Create a project in Eclipse Step 6 : Do a right click on Project - Team - Share - Add to git repo Step 7 : Commit and Push the project to the repo Step 8 : Commit and Push every change to the repo

Thursday, April 23, 2020

Remotely related to java :-)

How to run minecraft on your PC (Java version) - note, Java edition does not support cross platform:

https://www.h3xed.com/pc-gaming/start-a-minecraft-server-and-play-with-your-friends

To check your external ip:
https://www.whatismyip.com/

To check if your port is open:
https://www.yougetsignal.com/tools/open-ports/


Sunday, April 19, 2020

Very good reference on using Jersey:
https://dennis-xlc.gitbooks.io/restful-java-with-jax-rs-2-0-en/cn/part1/chapter8/building_and_invoking_requests.html


Do note: need to do a string:
Response resp = invocationBuilder.post(Entity.entity(jsonObjectBody.toString(), MediaType.APPLICATION_JSON)); 

or else json
{"method":"Logon","payload":{"strLogin":"aaa_offers","strPassword":"gL(8KKw3L)\\\"g)BKR","elemParameters":{}},"schema":"xtk:session","securityToken":"","sessionToken":""}


will be converted to like NVP:

{
               "method": {
      "chars": "Logon",
      "string": "Logon",
      "valueType": "STRING"
    },
    "payload": {    
      "strLogin": {
        "chars": "aaa_offers",
        "string": "aaa_offers",
        "valueType": "STRING"
      },
      "strPassword": {
        "chars": "**** password here ****",
        "string": "**** password here ****",
        "valueType": "STRING"
      },
                 "elemParameters": {}
    },
    "schema": {
      "chars": "xtk:session",
      "string": "xtk:session",
      "valueType": "STRING"
    },
    "securityToken": {
      "chars": "",
      "string": "",
      "valueType": "STRING"
    },
    "sessionToken": {
      "chars": "",
      "string": "",
      "valueType": "STRING"
    }
  }

Saturday, April 18, 2020

Jersey Logging

Not easy to do with Jersey 2 but here's a good one to start with:
https://www.javaguides.net/2018/06/jersey-rest-logging-using-loggingfeature.html

And here is how to bridge it to log4j:
https://stackoverflow.com/questions/15437043/how-to-use-log4j-to-see-into-jersey

https://xiaozhoutech.wordpress.com/2013/08/02/log4j-working-on-jersey/

http://jersey.576304.n2.nabble.com/Enable-Logging-td7581002.html


OK folks, this one works:
https://www.logicbig.com/tutorials/misc/java-logging/jul-to-slf4j-log4j2.html

Will post code later

Getting started on Maven

Trying this out now, coz I realised this is the easiest way to ensure I am using the latest jars that I need for my development work.

See this for starters: https://www.vogella.com/tutorials/EclipseMaven/article.html

If you get the error "maven could not resolve archetype", try the suggestions in these 2 links:
https://stackoverflow.com/questions/15506043/create-a-maven-project-in-eclipse-complains-could-not-resolve-archetype
https://stackoverflow.com/questions/18499931/eclipse-java-ee-new-maven-project-could-not-resolve-archetype

To setup Eclipse with M2E:

Way 1: Maven Eclipse plugin installation step by step:
  1. Open Eclipse IDE
  2. Click Help -> Install New Software...
  3. Click Add button at top right corner
  4. Now click OK
After that installation would be started.
Way 2: Another way to install Maven plug-in for Eclipse by "Eclipse Marketplace":
  1. Open Eclipse
  2. Go to Help -> Eclipse Marketplace
  3. Search by Maven
  4. Click "Install" button at "Maven Integration for Eclipse" section
  5. Follow the instruction step by step
After successful installation do the followings in Eclipse:
  1. Go to Window --> Preferences
  2. Observe, Maven is enlisted at left panel
Finally,
  1. Click on an existing project
  2. Select Configure -> Convert to Maven Project