Hemnathbabu Kottaiveedu

Greenhorn
+ Follow
since Mar 13, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hemnathbabu Kottaiveedu

I am able to execute the above referenced program from a directory under it as well from a directory above it. I think there might be some syntax error on the command line when you are trying at your end. Following are the commands which I executed.

java -cp ..\ A (This is from the test\woo\com\src\classes dir)



java -cp src A (This is from the test\woo\com dir)



Following is a snippet of the output from the program

-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:\Program Files\Java\jre6\bin
java.vm.version=19.1-b02
sdsd sdfs=dsfs sdfs
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io



Hope this helps !

Thanks,
Hemnath
Very well explained Micha!!. I agree with you.

Thanks,
Hemnath
Hi Priyadarshini,

can you please tell us what is the answer as per your understanding?

I believe that the answer which you have mentioned is not correct.

Thanks,
Hemnath
Hello All,

We are trying to generate the deployment code of ejb using the ant ejbjar optional task. The deployment code is generated properly using the WSAD v 5.1.2 but it fails when we use the ejbjar task of ant. Following is the snippet of our build.xml:





[*Error] ejbModule/updateFNORA/EJSStatelessUpdateHomeBean_4d6c968d.java(8): EJSHome cannot be resolved or is not a valid superclass
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateHomeBean_4d6c968d.java(18): BeanO cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateHomeBean_4d6c968d.java(22): BeanId cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateHomeBean_4d6c968d.java(32): CreateFailureException cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateHomeBean.java(6): The hierarchy of the type EJSStatelessUpdateHomeBean is inconsistent
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateCitiScanHomeBean_14c3694e.java(8): EJSHome cannot be resolved or is not a valid superclass
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateCitiScanHomeBean_14c3694e.java(18): BeanO cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateCitiScanHomeBean_14c3694e.java(22): BeanId cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateCitiScanHomeBean_14c3694e.java(32): CreateFailureException cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSStatelessUpdateCitiScanHomeBean.java(6): The hierarchy of the type EJSStatelessUpdateCitiScanHomeBean is inconsistent
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): Class must implement the inherited abstract method EJBObject.remove()
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): Class must implement the inherited abstract method EJBObject.getEJBHome()
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): Class must implement the inherited abstract method EJBObject.isIdentical(EJBObject)
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): Class must implement the inherited abstract method EJBObject.getPrimaryKey()
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): Class must implement the inherited abstract method EJBObject.getHandle()
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(8): EJSWrapper cannot be resolved or is not a valid superclass
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(17): com.ibm.ejs.container.EJSDeployedSupport cannot be resolved (or is not a valid return type) for the method getDeployedSupport
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(18): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(23): com.ibm.ejs.container.EJSDeployedSupport cannot be resolved (or is not a valid type) for the argument support of the method putDeployedSupport
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(24): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(31): EJSDeployedSupport cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(31): The method getDeployedSupport() is undefined for the type EJSRemoteStatelessUpdate_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(34): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdate_4d6c968d.java(62): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(31): EJSDeployedSupport cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(31): The method getDeployedSupport() is undefined for the type EJSRemoteStatelessUpdateHome_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(34): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(35): The method getEJBMetaData() is undefined for the type EJSStatelessUpdateHomeBean_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(47): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(58): EJSDeployedSupport cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(58): The method getDeployedSupport() is undefined for the type EJSRemoteStatelessUpdateHome_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(61): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(62): The method getHomeHandle() is undefined for the type EJSStatelessUpdateHomeBean_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(74): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(85): EJSDeployedSupport cannot be resolved or is not a type
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(85): The method getDeployedSupport() is undefined for the type EJSRemoteStatelessUpdateHome_4d6c968d
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(88): container cannot be resolved
[*Error] ejbModule/updateFNORA/EJSRemoteStatelessUpdateHome_4d6c968d.java(105): container cannot be resolved and many more.....

Can anyone tell why these errors are coming up?

Thanks in advance
12 years ago
Many Congrats

Keep it up!!!
12 years ago
HI Sunil,

The output of 20 is correct. You need to understand in this program that there are two variables 'i' with the same name. one is an instance variable(int i=20) and the other is a local variable (scope limited to the static block). Now in the main method an instance of class is created and using that instance the variable i is accessed and hence the value is 20.

The variable i declared in the static block cannot be accessed from the main method because of its limited scope. You can modify the above program as:


Now the output will be 10 because the scope of variable j is now extended and it can be accessed anywhere within the same package.

Thanks,
Hemnath
Hi Michael,

Even I had faced similar kinds of doubt when I was learning about threads. The output which you are expecting is not possible in this code. You are assuming that the notifyAll() method will actually release the lock on the object. But it is not so. The notifyAll() method informs the other waiting thread that the lock will be released soon and you can obtain the lock. Though the lock is actually released only after the entire syncronised block is executed. Till the time the thread is executing the code in synchronized block the lock is retained by the current thread and that what happens when the thread B sleeps the lock is still with it.

Hope this helps you in understanding why the output is not as expected by you.

Thanks
Hemnath
Hi Nancy,

Are you sure that your code compiled when you commented the lines 4 and 5? It did not compile fine when I tried to do it.

It gave an error saying that the show6() method in the child class must throw IOException or it must be caught. After commenting the line throw new IOException(); your code compiled fine.

Now when the lines 4 and 5 are uncommented then there you are trying to implement polymorphism which is a runtime phenomenon. So at compile time the Parent class show6() method is referred and hence the compiler gives the error.

To compile that code you need to put the p.show6() code in a try catch block or declare the main method as throwing the IOException.

Hope this helps you.

Thanks,
Hemnath
Hi Nancy,

Are you sure that your code compiled when you commented the lines 4 and 5? It did not compile fine when I tried to do it.

It gave an error saying that the show6() method in the child class must throw IOException or it must be caught. After commenting the line throw new IOException(); your code compiled fine.

Now when the lines 4 and 5 are uncommented then there you are trying to implement polymorphism which is a runtime phenomenon. So at compile time the Parent class show6() method is referred and hence the compiler gives the error.

To compile that code you need to put the p.show6() code in a try catch block or declare the main method as throwing the IOException.

Hope this helps you.

Thanks,
Hemnath
Hi James,

The super() method called in the constructor of the objecttest class calls the constructor of the default Object class of the java.lang package.

You need to extend the Object class in the objecttest class to print your expected output.

class objecttest extends Object

Thanks
Hemnath
Yes why not.

When you execute the renameTo method on the file object the original file(f1 with abs path pack1\niky.txt) is renamed with the abs path of f2(pack2\rex.txt). So the file location is changed and you will find the file created in pack2 directiory.

And the system out statements that you have put at the end of the program clearly shows that f1 is no more a file now and f2 is actually pointing to a file with name rex.txt.

Thanks,
Hemnath
Hi Kedar,

The code
renames the file referenced by variable f1 to the abstract file name of f2. The abstract path names of f1 and f2 are:

f1: pack1\niky.txt
f2: pack2\rex.txt

So after the above code is executed you will observe that the file name of f1 is changed to pack2\rex.txt and therefore you will find rex.txt file created under pack2 dir. So after the code is executed f1 is pointing to a file object which is still not created and f2 is pointing to an actual file on disk.

Hope this clears your doubt.

Thank You
Hemnath
Hi Preetha,

There are two forms of return statements that can be used depending on whether the method is a void or non void method.
return Statement
Form of return Statement In void Method In Non-void Method

return; optional not allowed

return <expression>; not allowed mandatory

So c is not reached because the flow of execution is transfered to the point from where the main() method has been called.

Hope this helps you!

Thanks
[ November 20, 2008: Message edited by: Hemnathbabu Kottaiveedu ]
Hi Jones,

Your doubt is very obvious. I tried for around 45 min. to find out why the compilation is failing. Finally I got that.

The default constructor generated by compiler has same access modifier as of the class. So a protected constructor is generated which can be accessed in other packages only by classes which extend that inner class. I changed the code as below and it has compiled fine now.


Hope it clears your doubt.
Hi,

I guess you are clear with the most positive value that will be returned after a successful search i.e. 4 because there are only 5 elements present.

Now if we consider the results for negative values i.e. for the insertion of elements to maintain the sort order then there are three cases which we can have:

1. Insertion at the start of the Array i.e. at index 0 : In this case the binarySearch will return [-(insertion point)-1] i.e. [-(0)-1]=-1

2. Insertion at the end of the Array i.e. at index 5(Not 4 because a new element needs to be added) : For this the result will be [-(5)-1]=-6

3. Insertion at any place other than the above two: In that case the result will be between -2 and -5 both inclusive.

I hope you this should help you!!!

Thanks
Hemnath