Thursday, February 19, 2015

Thread Vs Runnable

When somebody asks about thread in java, obviously anybody's answer will be..
There are two types of ways to implement Threads in Java.
1. Extends Thread class
2. Implement Runnable

Above answer is based with java 1.5 and prior versions and Threads has more better implementations with 1.5 and later versions.
I am  not going to go through those and just look at Thread class Runnable interface.

Both has common functionality. That is to facilitate programmer to write a thread or letting programmer to implement some work within a thread without worrying much about thread mechanism.

So how java let you to do your work in the thread.

Very simple. Java has given run() method.
So whatever you need to do it inside a thread or the work to be done concurrently must be implement inside run() method.

So it is very simple..

So explain in literature...  override run() method with concurrent functionality.

So if both these give override over run() method, then why we have two options.
Is it cause one is legacy and other is newer.
Answer is no.

It has more depth. It can be explained with adhere to principles like Open close principle , Liskov substitution .. etc. You can find more details about those principles on the web.

So let's go into detail analysis

First we take Thread class. We can simply create thread by Extends with Thread class. Override run() method. create instance of the class and simply call thread functionality, start() method to run the thread.

Below is an example :
MyThread class is extends Thread class.
I have included constructor with name and set the name for thread with calling super constructor method. This is optional. But with this you can set the name for thread as it creates.
Then we have run() method. This is where logic or the work of the thread resides.

In this thread I have initialized int variable , count
Inside run() method, I increment count and print the value.

So this is an implementation of a "MyThread" thread. you can test with creating instance of "MyThread"  and simply calling start() method.
----------------------------------------------------------------------------------------------------


public class MyThread extends Thread {

int count = 0;

public MyThread(String name) {
super(name);
}

@Override
public void run() {
for (int i = 0; i < 3; i++) {
count++;
System.out.println("MyThread count="+count);
}
}
}

-------------------------------------------------------------------------------------------------------

Below shows testing of MyThread  class.
I have created Compare class to test the Mythread class which will be used to compare the Runnable implementation with Thread extension.

--------------------------------------------------------------------------------------------------------
public class Compare {

public static void main(String[] args) {
MyThread t1 = new MyThread("t1");
MyThread t2 = new MyThread("t2");
MyThread t3 = new MyThread("t3");
t1.start();
t2.start();
t3.start();
}
}
-----------------------------------------------------------------------------------------------------------

Out of the Compare class as follows
-----------------------------------------------------------------------------------------------------------
MyThread count=1
MyThread count=1
MyThread count=2
MyThread count=3
MyThread count=1
MyThread count=2
MyThread count=2
MyThread count=3
MyThread count=3

-----------------------------------------------------------------------------------------------------------
 As I have created three threads and one thread print three numbers with starting 1 and ending 3 , thus will have three sets of
MyThread count=1
MyThread count=2
MyThread count=3

as theses are threads, there output may vary. Thread executes asynchronously. that is threads context switch with each other , in simple the execution has no real execution order.  Or in other way one thread need not to wait until the finish of other thread - that is the basic need of the thread.

So if we assume all three threads execute successfully, then we need to have 3 occurrences of
MyThread count=1
MyThread count=2
MyThread count=3

where    MyThread count=1, MyThread count=2 ,MyThread count=3 may print in different oder each time of Compare  main method executes.

For better understand, we can modify our MyThread run() method to print the name of the thread execution. So modification will be as follows.

-----------------------------------------------------------------------------------------------------------
public class MyThread extends Thread {

int count = 0;

public MyThread(String name) {
super(name);
}

@Override
public void run() {
for (int i = 0; i < 3; i++) {
count++;
System.out.println("MyThread "+Thread.currentThread().getName()+ " count="+count);
}
}
}

-----------------------------------------------------------------------------------------------------------


Output as follows. Note I have given names to threads as t1, t2, t3
You can observe that execution order differ from thread start order.

-----------------------------------------------------------------------------------------------------------
MyThread t2 count=1
MyThread t2 count=2
MyThread t2 count=3
MyThread t3 count=1
MyThread t3 count=2
MyThread t3 count=3
MyThread t1 count=1
MyThread t1 count=2
MyThread t1 count=3

-----------------------------------------------------------------------------------------------------------
If we get another output, it will be totally different.
-----------------------------------------------------------------------------------------------------------
MyThread t1 count=1
MyThread t3 count=1
MyThread t2 count=1
MyThread t2 count=2
MyThread t2 count=3
MyThread t1 count=2
MyThread t1 count=3
MyThread t3 count=2
MyThread t3 count=3
-----------------------------------------------------------------------------------------------------------

I Believe this would give you a clear picture of thread execution at glance, and let's stick to our discussion over creating Thread with extending Thread class Vs Implementation of Runnable.

So we have implemented thread simply with extending a thread class and our work has been implemented inside run() method.
That's it. very simple.
So what's the issue ????
Can you see something with MyThread class ??
it has already one extends, Thread class -- We cannot extends another class
That's a problem we have with Thread extends..

So how to get over with.
Java has given contract , Runnable interface with only run() method
Second way of creating a thread.

Question: Why we need to create a thread ???
Answer :  cause we need to do some work in asynchronously ..

OK.override the logic, work in run() method

Question: can we take the run() outside Thread class , so we can extends our thread "in the case MyThread"  with specific class and do the thread work separately.
Answer :  That's where Runnable  comes.

So let's implement same logic using Runnable

-----------------------------------------------------------------------------------------------------------

public class MyRunnable implements Runnable {

int count = 0;

public void run() {
for (int i = 0; i < 3; i++) {
count++;
System.out.println("MyRunnable " + Thread.currentThread().getName()+ " count=" + count);
}

}
}

-----------------------------------------------------------------------------------------------------------

So we have run() method override

Question: How we are going to run this thread. MyRunnable  class does not have any thread functionality. start() method



Answer : Java has given you way
Question: How ???
Answer : we create thread with extends Thread class. it has all functionality of thread implemented inside of it. Why not reuse Thread class
Question: Great   .... How to reuse it.
Answer : Thread class has constructor to accept Runnable instance
Question: So we need to create instance of the Runnable and create Thread instance using Thread class
Answer : Yes
Question : We are creating two instances ??
Answer : Yes..

That's how we reuse the functionality.

Question : I don't like creating two instances for create one thread object. Isn't it taking more memory and space ?? I prefer extends Thread class.. So I can straight away start() thread with creating instance.

Answer : We have pros and cons in both ways. Don't be so lazy. Runnable is a better implementation over extends Thread. we can keep thread logic separately and also we can extends another class. Don't you remember the problem we had over extends with Thread where we cannot extends only one class.

Question :Ok. Let's agree Runnable is better .
Answer  : You will see more magic in future.

Below Is the execution of Runnable , corresponding to output "MyThread"

main method

----------------------------------------------------------------------------------------------------------------

public class Compare {

public static void main(String[] args) {
MyRunnable myRunnable1 = new MyRunnable();
MyRunnable myRunnable2 = new MyRunnable();
MyRunnable myRunnable3 = new MyRunnable();
Thread r1 = new Thread(myRunnable1, "r1");
Thread r2 = new Thread(myRunnable2, "r2");
Thread r3 = new Thread(myRunnable3, "r3");
r1.start();
r2.start();
r3.start();
}
}

----------------------------------------------------------------------------------------------------------------

Out as below

----------------------------------------------------------------------------------------------------------------
MyRunnable r1 count=1
MyRunnable r1 count=2
MyRunnable r1 count=3
MyRunnable r2 count=1
MyRunnable r2 count=2
MyRunnable r2 count=3
MyRunnable r3 count=1
MyRunnable r3 count=2
MyRunnable r3 count=3
----------------------------------------------------------------------------------------------------------------

So same thing is done using Runnable. But we need to write some additional lines to create instances of Runnable for each thread.

                MyRunnable myRunnable1 = new MyRunnable();
MyRunnable myRunnable2 = new MyRunnable();
MyRunnable myRunnable3 = new MyRunnable();

You can simply give the created object as reference as below if needed. Simple java programming way of writing..

-------------------------------------------------------------------------------------------------------------------
public class Compare {

public static void main(String[] args) {

Thread r1 = new Thread(new MyRunnable(), "r1");
Thread r2 = new Thread(new MyRunnable(), "r2");
Thread r3 = new Thread(new MyRunnable(), "r3");
r1.start();
r2.start();
r3.start();
}
}

-------------------------------------------------------------------------------------------------------------------

It will produce same output
-------------------------------------------------------------------------------------------------------------------
MyRunnable r2 count=1
MyRunnable r2 count=2
MyRunnable r2 count=3
MyRunnable r1 count=1
MyRunnable r1 count=2
MyRunnable r1 count=3
MyRunnable r3 count=1
MyRunnable r3 count=2
MyRunnable r3 count=3

-------------------------------------------------------------------------------------------------------------------


So you don't have to worry about additional java code line writing.

So what's the other big deal with Runnable.???

With Runnable You can share the Runnable objet with threads. There by , we can pass process to another thread. Next thread will take upon from previous thread.

May be little confusing. Let's look at with the example.

Here we have created only once instance of Runnable and we have shared with three threads insteads.
Note : Shared 

New main method will be looks like this.
we have only one reference "myRunnable" and it is shared with all three threads.
-------------------------------------------------------------------------------------------------------------------
public class Compare {

public static void main(String[] args) {
MyRunnable myRunnable = new MyRunnable();

Thread r1 = new Thread(myRunnable, "r1");
Thread r2 = new Thread(myRunnable, "r2");
Thread r3 = new Thread(myRunnable, "r3");
r1.start();
r2.start();
r3.start();
}
}


-------------------------------------------------------------------------------------------------------------------

Output will be as follows.
-------------------------------------------------------------------------------------------------------------------
MyRunnable r1 count=1
MyRunnable r1 count=2
MyRunnable r1 count=3
MyRunnable r2 count=4
MyRunnable r2 count=5
MyRunnable r2 count=6
MyRunnable r3 count=7
MyRunnable r3 count=8
MyRunnable r3 count=9
-------------------------------------------------------------------------------------------------------------------


See the output. Now the count is incremented by each time a thread executes.
How this happens.
we have created one Runnable instance/Object. "myRunnable", It is shared with all three threads.
when object is shared its property " count " is shared between threads, thus increment each time run()  method executes.

So as a brief following will be the outcomes we must remember when considering Extends Thread over Implment Runnable.


  1.  Java doesn't support multiple inheritance, which means you can only extend one class in Java so once you extended Thread class you lost your chance and can not extend or inherit another class in Java.
  2. In Object oriented programming extending a class generally means adding new functionality, modifying or improving behaviors. If we are not making any modification on Thread than use Runnable interface instead.
  3. Runnable interface represent a Task which can be executed by either plain Thread or Executors or any other means. so logical separation of Task as Runnable than Thread is good design decision.
  4. Separating task as Runnable means we can reuse the task and also has liberty to execute it from different means. since you can not restart a Thread once it completes. again Runnable vs Thread for task, Runnable is winner. Reusability and Seperation.
  5. Java designer recognizes this and that's why Executors accept Runnable as Task and they have worker thread which executes those task.
  6. Inheriting all Thread methods are additional overhead just for representing a Task which can can be done easily with Runnable.
This is not the end. Java concurrency is a huge topic and let's go through one step at a time.
We have issues with the Thread and implementation of run() method, what to do if exception happens... how to handle those exceptions... can we return a value...

So next we look at Callable interface , which as some enhance functionality over Runnable.
Callable let's you return from run() method and handle exceptions. Java has change the name to call() - fair enough, that makes a difference and reduce the ambiguity also.

For Quick reviews on states, Threads has 4 different main states. New, Runnable, Running, Dead.
Runnable can be interchange with Running state and
Running state may go to Waiting/Blocked/(Sleep)
New - newly created thread is in this state.
Runnable -  once start() method called thread will be in Runnable state
Running - Runnable state will be picked and start executing , state will be Running - where thread actually does it work
Dead - once thread work finish, goes to dead state
Waiting/Blocked(Sleep) -  calling sleep, or with some interruption thread will be in Waiting/Blocked state. Once it come out from Waiting or Blocking thread will be in Runnable state.

Note: Thread class has yield() method. This will put Running thread back into Runnable state.
This it is said to be giving fair chance to all threads in the same priority as Yield() thread.
But as sleep(), it is also not guaranteed, same yield() thread may come back to Running straight after Runnable - thus not making fair chance to other threads in same priority.

Although we give the sleep time in millisecond, ex:500 mills , it is not guaranteed that it will be sleep for 500 mills . it can be start Running before after 500 mills.


One important method to remember is join(), where tells JVM to finish join thread before current thread.




Monday, February 16, 2015

Error in Iterrating over Entryset in Map

I just wrote a simple method to print the values of a given Map.
I gave the Map as a parameter for print Method and printing logic was implemented inside method.

But when i tried to iterate using simple "for loop" as below

--------------------------------------------------------------------------------------------------------

public static void printMapWithEntrySet(Map nameCount) {
for (Entry entry : nameCount.entrySet()) {
String key = entry.getKey().toString();

Integer value = entry.getValue();
System.out.println("key, " + key + " value " + value);
}
}

---------------------------------------------------------------------------------------------------------

there was a Type mismatch error
( "Type mismatch: cannot convert from element type Object to Map.Entry") 
showing in the highlighted line.

for (Entry entry : nameCount.entrySet()) {

I found the reason, it was very simple mistake. error is in the parameter.
I have not included type in Map definition the parameter.
It should be

Map nameCount

So the correct formation of the method would be

----------------------------------------------------------------------------------------------------------

public static void printMapWithEntrySet(Map nameCount) {
for (Entry entry : nameCount.entrySet()) {
String key = entry.getKey().toString();

Integer value = entry.getValue();
System.out.println("key, " + key + " value " + value);
}
}

----------------------------------------------------------------------------------------------------------

Because of that, Entry set object cannot cast the value for Entry and it comes as Object as stated below

----------------------------------------------------------------------------------------------------------

public static void printMapWithEntrySet(Map nameCount) {
for (Object entry : nameCount.entrySet()) {

}
}
----------------------------------------------------------------------------------------------------------


Without  the type definition of the Map , that is "" in  the parameter you can still implement the printing all values in a Map with using iterator.
So the code will looks like below.

----------------------------------------------------------------------------------------------------------
public static void printMap(Map nameCount) {

Iterator> it = nameCount.entrySet().iterator();
while (it.hasNext()) {
Entry pairs = (Entry) it.next();
System.out.println("key, " + pairs.getKey() + " value "
+ pairs.getValue());
}

}

----------------------------------------------------------------------------------------------------------

Here we have to use an Iterator. That is an additional burden.

Friday, February 13, 2015

Fibonacci Series

This is very popular basic question often asked from beginners to check their recursive algorithm knowledge. This it will lead to some performance question, not much hard , but to how to improve, with testing memorization concept.

Fibonacci series is a number series where each number is built with the sum of the following two numbers.
F_n = F_{n-1} + F_{n-2},\!\,

1, 1, 2,3, 5, 8, 13 ......

Or
 0, 1, 1, 2, 3, 5, 8, 13 .....

This can be done using recursive algorithm as below.

------------------------------------------------------------------------
public static Integer fibR(Integer number) {

if (number == 1 || number == 2) {
return 1;
}
return fibR(number - 1) + fibR(number - 2);
}

----------------------------------------------------------------------------

This has some small issue, where recursion will have duplicate calls to calculate same fibonacci value.
Image result for fibonacci recursion

eg: If we calculate Fibonacci(5) , or value of Fibonacci series at 5 th position, we need Fibonacci values from Fibonacci(0)  to Fibonacci(5)
But with recursive way , except for Fibonacci(5) , all values are called repetitively. This is a waste.

So what we need to do. There the question of memorization will come to action.
That is, if we can have the memory of the values we have already calculated, then we can reuse them, without recalculating.

So we need to functionality to be made.
1. Keep the calculated Fibonacci values in memory
2. Before calculating new value, check whether value is calculated and need to have a retrieving mechanism of stored value.

Note : recursive algorithm is calling all the nodes, until get the leaf node
(  depending on your definition of Fibonacci series , series will defines as fib(0) , fib(1), fib(2).... or fib(1), fib(2), fib(3)...   )
So in both cases leaf nodes will be fib(0) , fib(1),  or fib(1), fib(2) respectively.
calculation happens from bottom to top after calling to create each node.
So Recursive algorithm is bottom up.

Next when come to memorization , I have create in top down approach.

--------------------------------------------------------------------------------------------------------------------------

public static Integer fibM(Integer number) {
HashMap cache = new HashMap();
cache.put(1, 1);
cache.put(2, 1);

if (number == 1 || number == 2) {
return 1;
}

// for memorization, we go from top to bottom - fib(1) to fib(n)
for (Integer i = 3; i <= number; i++) {
cache.put(i, cache.get(i - 1) + cache.get(i - 2));
}

return cache.get(number);
}

--------------------------------------------------------------------------------------------------------------------------

I have used a HashMap to cache the calculated values and finally return the Fibonacci  value.

Thursday, February 12, 2015

Reverse Number and Check Number is Palindrome

I have explained previously about finding a Armstrong number. There we used modulus and division operators.
Same way we can reverse a given number, and one step ahead can check whether it is Palindrome.

what is Palindrome number ?
If any number equals its reverse number, we call them palindrome number.

So checking Palindrome we need to reverse the number.

So first look at reversing number.

--------------------------------------------------------------------------------
 public static int reverseNumber(int number){
        int reverseNumber = 0;
        int remainder = 0;
        do{
            remainder = number%10;
            reverseNumber = reverseNumber*10 + remainder;
            number = number/10;
         
        }while(number > 0);
     
        return reverseNumber;
    }

-----------------------------------------------------------------------
We use modulus to get the last digit of the number and rest of the numbers exclusive of last digit by division.

To check the palindrome ,  we can use this functionality.
Note: I have done using do while loop ,but this can be done using while loop as we have used in Armstrong number scenario.
So benefit i will use Palindrome number check with while loop.


------------------------------------------------------------------------------

public static boolean isPalindrome(int number) {
int palindromeNumber = number; // copied number into variable
int reverseNumber = 0;

while (palindromeNumber != 0) {
int remainder = palindromeNumber % 10;
reverseNumber = reverseNumber * 10 + remainder;
palindromeNumber = palindromeNumber / 10;
}

// original number equals reverse number , then it's Palindrome.
if (number == reverseNumber) {
return true;
}
return false;
}

-----------------------------------------------------------------------------------



Wednesday, February 11, 2015

Find Armstrong Number

I thought of sharing this little question with you all. This is very simple question, but which will put your analytical and technical approach in test.
First place Amstrong number , for those who have never heard this, it's a very wonderful arithmetic art or classic we observe with base ten (we are normally using our number is base 10 format,it can be any format - this is also known as Narcissistic Number).

Amstrong number is any number , where sum of its own digits raised to the power of number of digits.

eg : If we take three digit number, Amstrong number , where sum of cubic value of each digit number equals to the number.
If get a number xyz then ,
 eg:  xyz = x^3 + y^3 + z^3

For further explain, let's take Amstrong number 153

153 = 1^3 + 5^3 + 3^3 = 1 +125 +27 = 153

See how nice  is that.

We continue example with 3 digit number, and extend the program for any number.

So it's very simple arithmetic operation to check whether a number is Armstrong ,
1. break number in to digit
2. get the sum of  cubic  value of each number.

So when come to the  implementation of the logic step 1 is where you will be tested, break the number in to digits. Obviously step 2 has very little where  getting sum of each cubic value- very simple and straight forwards writing of same arithmetic operation in any language.

How to break the number in to digits.

You can come up with various solutions. Convert to String and make substrings of size one, convert to char array , but any operation relate with strings and characters will have high cost and some implementation logic.

But we can use division and modulus operator to achieve this. Below code snippet will show you the method to check whether number is Armstrong.

public class ArmstrongNumber {

/*
* @return true if number is Armstrong number or return false
*/
// how to create the logic.
// we need to get the each digit of the number one by one
// get the cubic value, value to the power three
// and get the sum of all cubic value
//
// how to get digit by digit
// we can have so many approaches
// simple arithmetic way is to use modulus to break to digits
// and division to break the number exclusive of modulus , like taking
// substring except last character
public static boolean isArmStrong(int number) {
int result = 0;
int orig = number;
while (number != 0) {
int remainder = number % 10;
result = result + remainder * remainder * remainder;
number = number / 10;
}
// number is Armstrong return true
if (orig == result) {
return true;
}

return false;
}

public static void main(String[] args) {
int number = 153;
System.out.println("Number " + number + " is Amstrong ="
+ isArmStrong(number));

}

}


----------------

If I am going to explain further

Modulus operator is used to break the number in to digits. In base ten , if we need to break number in to digits all we need to do is , get the modulus by ten where you can get the last number.
So from modulus we can the last number.
Now problem , how to break the remaining part and continue to get the last digit.

int remainder = number % 10;

It's very simple, as same as getting the modulus of ten to get the last digit, if we get the division value of that number from 10, then we get the remaining part of the number(two digits to right side) - which is obviously to the right side of the number.

number = number / 10;

Two simple operation to break then number.
We continue to replace the number with division value itself, until number becomes zero - where no number to divide (number has been reduced to one digit)

while (number != 0)


Same arithmetic logic can be used to check whether number in Palindrome and reverse a given number.


So above program is designed to only to 3 digits number, but the concept has been implemented. Only thing is to get the power to number of digits.
So how we can find the number of digits in any number.
We have mathematical solution.

If we take any number any base, we take the log value of the number in the same base we get one less of the number of digits in the number.

So as we discussed for base ten, we get the number of digits as, or in simple length of the number.

int length = (int)(Math.log10(n)+1);

taking the power of number , you can few ways

Math.pow(remainder, length); // where length is the power - this takes double values as input and returns double

BigInteger.valueOf(3).pow(length)  // BigInteger has pow() method which needs and instance.

any way I have done the example using "int" values and code looks like below

-----------------------------------------------------------------------

public static boolean isArmStrong(int number) {
int result = 0;
int orig = number;
int length = (int)(Math.log10(number)+1);
while (number != 0) {
int remainder = number % 10;
result = result + (int)Math.pow(remainder, length);
number = number / 10;
}
// number is Armstrong return true
if (orig == result) {
return true;
}

return false;
}

-------------------------------------------------------------------------




Tuesday, February 10, 2015

WebSphere End to End War deployment

Once you install and configured websphere with new profile, you can start deploy war files.
Start new profile.
from websphere customization tool box, you can see the servers
here in my case server2 -- AppSrv02

start server

https://localhost:9044/ibm/console/
https://localhost:9044/ibm/console/login.do?action=secure
(above port=9061 - port will be increase by one for each profile creation.)
will load login page for admin
user name and password = admin/admin

1. Increase heap size

"webshere application server"  under server--> server types-->



select "server1"

select "Process definition" under "Server Infastructure"


select "Java Virtual Machine"  under additional properties.

Step 04 (Set Initial heap size & Maximum heap size àApply àSave),
Don’t give your system’s complete RAM size as Max heap size.  Ex, if your system is having 5120 RAM don’t give MAX heap size as “4096”. Give it as “2048”


In my case I have 4GB ram with left some 2BG, i would rather give some 1000 plus value, you can increase this later. 



make sure you apply the changes and save them (save for the configuration file.)












Config Websphere

Unzip websphere to c:\
it will have folder structure like

C:\ibm-websphere\WebSphere\AppServer\profiles\AppSrv01\firststeps

Then go to above "firsteps"  folder and run the bat file in command prompt."firststeps.bat run"

C:\ibm-websphere\WebSphere\AppServer\profiles\AppSrv01\firststeps>firststeps.bat run

it will give you below screen.


take your browser and got to
https://localhost:9043/ibm/console

https://localhost:9043/ibm/console/logon.jsp

username and password = admin/admin

successful login will load admin console.




Create New Profile
-----------------

Click "webSphere customization Toolbox" in application server console menu, same console where you have start and stop server.



this will give following window



















click "create" and select "Application server"
























select "Next"
























select "Advance"


























Select "Next" - with default settings all deploy options
You will configuration window, where you can give name for the profile.

I have given default name "AppSrv02"





















click "Next"

Give server name, Node name and host name























Give user name and password, with enable administrative security.
Then you will get security Certificate Part 1
if you like you can use that. I do not , just click Next






















after that you will receive (Part 2) , showing all configuration values.Click "Next"



Next you will get Port values. Click Next
Give Web Server definitions
You can use default values
Then you will get Web server definition (part 2) , click Next
Finally the  --> Profile Summary.

click "create"
It will create the profile with given details and show you with profile creation summary.


You can start new profile with given window option or by going to location
C:\ibm-websphere\WebSphere\AppServer\profiles\AppSrv02\firststeps


WebSphere start error

when you start websphere for first time, you may have unzipped the folder to direct to C;\  in windows and would have tried to start firststep.bat

C:\ibm-websphere\WebSphere\AppServer\profiles\AppSrv01\firststeps

this would have given error  something like "cannot find the path specified."

This happens cause , due to little mistake in unzipping the websphere. check whether you zipped folder has duplicated "ibm-websphere"  directory.
which results as

C:\ibm-websphere\ibm-websphere\WebSphere\AppServer\profiles\AppSrv01\firststeps

Showed in bold steps.

So make sure when unzip , give to C;\ itself  , rather than giving a extract folder.