Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!

Keith Tingle

+ Follow
since Jan 12, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Keith Tingle

I think Corey has already answered this question in a previous post.

The operands of all bitwise operators are implicitly casted to integers before anything happens. So when I cast 0x80 to byte I am actually promoting 0x80 to 0xffffff80 (integer value -128).

In its literal form java does not upcast the 0x80.
This code;

int test = 0;
test |= 0x80;

produces test = 0x80 in the debugger, which is what you would probably expect.

this code however;

int test = 0;
test |= (byte)0x80;

produces test = 0xffffff80

Can anyone explain this? Is there anyway to perform an unsigned OR like we have in C?
What is the standard way to open files larger than 2GB in java?
16 years ago
Used Dan's mock exams and Kathy's book. I had about 10 years of C++ experience, and used the SCJP exam as a way to get familiar with Java.

No matter how I did on the exam it was worth my time, Java and C++ are more different than they are alike.

I wouldn't have taken the exam had I not found this site's forums.

I would like to continue Java certification, in particular design methodologies and UML, any suggestions about where to go from here?

17 years ago
Unless you inform the java compiler that you want 1.4 source compatabilty (-source 1.4) it will not consider 'assert' a keyword.

The only error I get on this code is 'unreachable code' for the the final assert.

IBM JDK 1.4.2.
I think this code is the functional equivlant:

byte B = -32;

// implicitly widen
int C = B;

System.out.println("C = " + C + " (0x" + Integer.toHexString(C) + ")");

// bit shift as an int
C >>= 1;

// narrowing cast
B = (byte)C;

System.out.println("C = " + C + " (0x" + Integer.toHexString(C) + ")");
System.out.println("B = " + B);


C = -32 (0xffffffe0)
C = -16 (0xfffffff0)
B = -16

Replace C >>= 1 with C >>>= 1 and the output becomes:

C = -32 (0xffffffe0)
C = 2147483632 (0x7ffffff0)
B = -16

So the unsigned shift behaves as advertised but on an integer primitive not a byte, so the -16 result for B is a product of a narrowing cast where the three highest bytes are lopped off the resulting integer.
Is there a way to view an int or char primitive in its hexadecimal representation in the Eclipse debugger?
I was reading Corey's journal article about bit shifting, and while typing in some code to see some shifts in the debugger, I ran into this:

// -32 = 11100000
byte A = -32;
A >>= 1;

byte B = -32;
B >>>= 1;

System.out.println("A -> " + A + " B -> " + B);

What would you expect to see here and why?

I expected B to be a positive number since the sign bit would be shifted to the right and a zero would be inserted into the sign bit.

This is the output of the above code:

'A -> -16 B -> -16'

Does this behavior have to do with the implicit casting of the arguements to the shift operators as ints?
[ August 30, 2004: Message edited by: Keith Tingle ]
I noticed this exam on the Sun certification site.

What is it all about?
I have a web application that basically acts as a batch process starter.

I have long batch processes that I dispatch off to threads, the servlet call that kicks this process off returns after setting up the batch process and creating the 'worker' thread.

So long after the servlet has done its HTTP work, the worker thread the servlet created is running its little heart out processing the batch job.

I would like my users to be able to visit a JSP or servlet page and check on the thread, perhaps get a quick report on what record the batch is processing, maybe cancel the job if needed etc...

It occurs to me that the best way to this is some kind of in-memory hash table with an auto-generated key that I return to my users. If they want status, they ask for it with the key, I use the key to look up the Runnable object and query for status.

Where is the best place to keep this hash table? It basically needs to be a global object accessible by servlets and my worker thread alike (for clean up).

Is there a standard approach to this kind of global object? I assume JNDI and a servlet context is the normal place for this sort of thing, are there any drawbacks?
17 years ago
In case anyone has problems getting this stuff to work here is how I did:

Grabbed Ant 1.6, Windows->Prefrences->Ant->Runtime removed the ant plugin jars and added 29 ant jars from ANT_HOME/lib, EXCEPT the two xml jars (xercesImpl.jar & xml-apis.jar). Then set ANT_HOME to my ant dist directory (C:\apache-ant-1.6.0\lib). That got Ant 1.6 working.

Then I added the following to the top of my build.xml file:

<property name="axis.home" location="C:\Lib\axis-1_1"/>
<property name="target.server" value="localhost"/>
<property name="target.port" value="8080"/>

<path id="axis.classpath">
<fileset dir="${axis.home}/lib">
<include name="**/*.jar" />

<taskdef resource="" classpathref="axis.classpath"/>

and booom everything works, I never had to add axis-ant.jar to the ant runtime classpath in Eclipse which is good for moving the project about.

Hope this saves someone the few hours I put into it.

[ June 25, 2004: Message edited by: Keith Tingle ]

[ June 25, 2004: Message edited by: Keith Tingle ]
[ June 25, 2004: Message edited by: Keith Tingle ]
I would like to use the ant tasks supplied by the axis folks in my Eclipse java project.

I have tried adding axis-ant.jar to classpath via the Preferences -> Ant -> Runtime -> Classpath, tried adding the entire axis/lib directory to the classpath.

I get the old 'Could not create task or type of type: axis-~~'.

How can I make the axis ant tasks visible to the ant plug-in?
[ June 24, 2004: Message edited by: Keith Tingle ]
I have a project checked out of my CVS respository, and I have made a great deal of changes.

I have grown weary of the changes I made and would like to start over, with a clean copy of the code from CVS.

At the command line I would use the -C switch:

cvs update -P -d -C (in directory C:\Eclipse2.1.3\workspace\<my project>\)

How would I do something similar in Eclipse.

Additionally, I very much enjoy the CVS console view, and have added to most of the perspectives I use. The only thing that frustrates me is I would like to use the console to enter CVS commands as if I was at the command line, is there any way to achieve this with Eclipse?

Thanks in advance for your time
[ June 22, 2004: Message edited by: Keith Tingle ]
Thank you Lasse!
17 years ago
Are there any popular utilities out there for generating key pairs or do most folks roll thier own with
[ June 15, 2004: Message edited by: Keith Tingle ]
17 years ago