ying lam

Ranch Hand
+ Follow
since May 17, 2004
Merit badge: grant badges
For More
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 ying lam

Hi,

How can I pass a C pointer to a byte array and its length to Java using JNI?
The example I find are just passing integer. How can I pass a byte array and its length?

Thank you for any pointers.
14 years ago
Can you please tell me what is the benefit of benefit of declaring a 'static interface class' inside a class?

I can declare a package visible interface class , right? What is the advantage of doing a 'static interface class'?
15 years ago
Hi,

Can you please tell me how can I inherit from an inner class of another class?



I get an error saying "No enclosing instance of type A is assessible to invoke the super constructor and explicitly qualify its super constructor innvocation with an instance of A.

Thank you.
15 years ago
Hi,

Does Swing JTabbedPane add scroll when there are too many tabs opened?
like in Mozilla Firefox, when I add a lot of tabs, a Left,Right arrow shows up so that I can navigate thru tabs.
Can you please tell me if Swing JTabbedPane have the same effect?

Thank you.
15 years ago
Hi,

I need to write unit test for my Java template class.

what is the right way to do that?

Thank you.
15 years ago
Hi,

I am trying to how to execute a system command in java.

Here is the code:

String cmd = "/usr/bin/pkill -9 -f " + "\'"+ getKillCmdLine() +"\'";
Runtime.getRuntime().exec(cmd);

My getKillCmdLine() returns


/home/yinglcs/bin/Main 9091 -DService10000000



(node there is space in the string.

But my code always fail with this:

- /usr/bin/pkill: invalid option -- 'D'
Usage: pkill [-SIGNAL] [-fvx] [-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]
[-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] [PATTERN]


I think the string does not get escaped "\'" and Runtime.getRuntime().exec() thinks '-D as an argument to the pkill command.

Can you please suggest any idea how to get this to work?

I try wrapping my string with ' and " and \"
String cmd = "/usr/bin/pkill -9 -f " + "'"+ getKillCmdLine() +"'";
String cmd = "/usr/bin/pkill -9 -f " + "\""+ getKillCmdLine() +"\"";

All does not work.

Thank you for any pointers.
15 years ago
I ask because I need to know what data structure needs to be synchronized.

For example, i need to build a blackjack game in j2me.

I have a button called 'Hit' (means add a card to my current hand).

And in my paint() method, it will paint all the cards in my current hand.

So do I need to be synchronized when I add a new card to my current hand.

Thank you.
15 years ago
Hi,

If my midlet does not create any thread, how many threads are created by JME VM when running my midlet?

1. Main thread for my application?
2. Display thread for painting my applicaition?
3. Event handling thread when users click any key?

Thank you.
15 years ago
Hi,

I am reading the following source code:

class secondCountDownRunner implements Runnable{
@Override
public void run() {
// ..implementation of the run method
}
}

And I have a question about @Override annotation. What does it do? Why i need to put it in my code? Isn't compiler know i am implementing the run()
of the Runnable interface?

Thank you.
15 years ago
Thank you.

You said, for the static inner class case:


Inner could still access "i" in an Outer object, but there's not an implicit Outer object as there is in this example



How canit access 'i' in an outer object if the above code you shown won't compile once you make the class 'static inner'.
15 years ago
Hi,

Can someone please tell me what are the difference between static inner class and inner class? I know both can access the outer class private and protected attributes, but what are the difference between 'static' vs 'non-static'?

And when I should use which one?
15 years ago
Thank you for all the help.

I have this in my code:



And i have a breakpoint in my msg getTitle() method. It does break (calling from tomcat) and the function does return the right value.

But why in my final page (view source in a browser), i only see

15 years ago
JSP
Thank you.

For my case of 'session' scope. Where I should I put my Msg object with the key 'msg' so that JSP can see it when I dispatch to it from the servlet.

Thank you.
15 years ago
JSP
Hi,

I set attribute 'msg' in my servletContext, like this, before I dispatch to a JSP.



And In my JSP, I try to access the 'msg' object like this:



But I get an error like this when I run:




Can you please tell me what did i do wrong?

Thank you.
15 years ago
JSP
Thanks for the reply. But I always do this.
So I don't think i can use a statement which is closed.