How to pass values to .bat file

Inside the .bat file:

setlocal

set variableName1=%1
set variableName2=%2
set variableName3=staticValue

 

call mvn install:install-file -Dfile=”%variableName1%\abcd.jar”

 

Advertisements

Interface vs Abstract class

Interfaces

An interface is a contract: the guy writing the interface says, “hey, I accept things looking that way“, and the guy using the interface says “Ok, the class I write looks that way“.

An interface is an empty shell, there are only the signatures of the methods, which implies that the methods do not have a body. The interface can’t do anything. It’s just a pattern.
Implementing an interface consumes very little CPU, because it’s not a class, just a bunch of names, and therefore there is no expensive look-up to do. It’s great when it matters such as in embedded devices.

// I say all motor vehicles should look like this:
interface MotorVehicle
{
    void run();

    int getFuel();
}

// my team mate complies and writes vehicle looking that way
class Car implements MotorVehicle
{

    int fuel;

    void run()
    {
        print("Wrroooooooom");
    }

    int getFuel()
    {
        return this.fuel;
    }
}

Abstract classes

Abstract classes, unlike interfaces, are classes. They are more expensive to use because there is a look-up to do when you inherit from them.

Abstract classes look a lot like interfaces, but they have something more : you can define a behavior for them. It’s more about a guy saying, “these classes should look like that, and they have that in common, so fill in the blanks!”.

e.g:

// I say all motor vehicles should look like this :
abstract class MotorVehicle
{

    int fuel;

    // they ALL have fuel, so why not let others implement this?
    // let's make it for everybody
    int getFuel()
    {
         return this.fuel;
    }

    // that can be very different, force them to provide their
    // implementation
    abstract void run();

}

// my team mate complies and writes vehicle looking that way
class Car extends MotorVehicle
{
    void run()
    {
        print("Wrroooooooom");
    }
}

Eclipse optimization

It’s better to use latest version of Eclipse, which is Mars 2, as of now. Also it’s recommended to use Java 8 for faster loads. You can add this configuration to the eclipse.ini file, make sure that you put the correct path to javaw.exe:

-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417
-product
org.eclipse.epp.package.jee.product
–launcher.defaultAction
openFile
–launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
512m
–launcher.defaultAction
-vm
C:/Program Files/Java/jdk1.8.0_74/bin/javaw.exe
openFile
–launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms1536m
-Xmx2048m
-XX:+UseParallelGC
-Xverify:none

Conflicts with repository

It may happen that your code no longer is latest version. Therefore you need to get latest code from repository, but if you do so, the changes you made will be lost.
Therefore this is the steps needs to be done to remove the conflicts.

1. Try to commit your code
2. Eclipse will tell that your code is not latest from repository
3. Click the Synchronize SVN button
4. The files you wanted to commit become red
5. Open one of the files, look at the right corner of the compare window
6. If the little square there is blue(or looks like black) then you can proceed with automatic merger. it’s called “Copy All Non-Conflicting Changes from right to left”
7. Then right click on the file and “Mark as Merged”
8. The file is ready to be committed.

Note, if the square on the right top corner is red, you should do manual merge.

Static block

Static blocks are nothing but a normal block of code, enclosed in braces { }, preceded with static keyword. These static blocks will be called when JVM loads the class into memory. Incase a class has multiple static blocks across the class, then JVM combines all these blocks as a single block of code and executes it. Static blocks will be called only once, when it is loaded into memory. These are also called initialization blocks.

package com.java2novice.staticexmp;
 
import java.util.ArrayList;
import java.util.List;
 
public class MyStaticBlock {
 
    private static List<String> list;
     
    static{
        //created required instances
        //create ur in-memory objects here
        list = new ArrayList<String>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
    }
     
    public void testList(){
        System.out.println(list);
    }
     
    public static void main(String a[]){
        MyStaticBlock msb = new MyStaticBlock();
        msb.testList();
    }
}

 

Output:
[one, two, three, four]