This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

d jones

Ranch Hand
+ Follow
since Mar 13, 2006
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 d jones

Hi,

how can I find out which JRE runtime versions I have installed on a machine?

Many Thanks
12 years ago
Is it possible to determine where java is writing its standard output?

If we start a program with "java testProgram > logfile.log"

Is it possible to identify in the program that it is writing its standard output to a file called logfile.log?

Many Thanks
12 years ago
Hi,

I am just trying to understand how Java Core Dump files work.

How are they enabled? When are they generated? What information do they contain? Where are they stored when generated?

If anyone has any good links to any site on the web I would greatly appreciate them. Or provide answers for the above questions.

Thanks
13 years ago
Thanks Henry,

I got a response on the Sun forum as well. Seems like a plausible explanation!?!

http://forum.java.sun.com/thread.jspa?threadID=5165192&tstart=0
Thanks Henry,

yep, it is definitely very similar and I was just thinking of making the Dateformat variable local to the method instead of an instance level variable. But I want to make sure that this is the cause of the problem first. I want to clarify something first ....

I can understand why it would be a problem if different threads were changing the format of the DataFormat object. If one thread requests a new format then another thread could potentially change the format before the original thread had a chance to parse the date with the format it requested.

But since no thread is changing any attribute in this object and they are all sending their own local (i.e. method) variable to this object then I wouldn't have expected it to cause a problem .... hmmmm...just thinking again... unless the parameter to the parse method is being assigned to an instance level variable in the DateFormat class (I doubt this though!).

I don't really understand why 2 threads each sharing the same object (DateFormat) would get confused if neither of them modify an instance level variable of this class.

My apologies if I offended anyone by posting in two different forums. Can understand that it might be wasting multiple persons time by working on the same issue. Maybe I should have included a link in my original posting indicating that I had posted on the Sun forums as well. That way anybody working on it can check if it has been answered on either forum.

Thanks
Why is it impolite?

Should I ever only post a specific question on 1 forum?

Is that a new rule on Java Ranch?!?

Just trying to increase my chances of coming across somebody who can answer my question.
I am using the DateFormat class to parse a date from a String. It works fine alomost all the time but I then sometimes get
the following exception:
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.text.DigitList.getLong(Unknown Source)
at java.text.DecimalFormat.parse(Unknown Source)
at java.text.SimpleDateFormat.subParse(Unknown Source)
at java.text.SimpleDateFormat.parse(Unknown Source)
at java.text.DateFormat.parse(Unknown Source)

I read in the following posting that the DateFormat class is not thread-safe: http://forum.java.sun.com/thread.jspa?threadID=497693&messageID=2906187

In my situation I have a singleton class which is used by multiple threads at the same time. The DateFormat variable is
an instance-level variable. But the date format is not changed by any thread. It is the same for all threads. Therefore,
I am thinking that the problem described in the above forum posting isn't the actual cause of my exception??

Would appreciate other views on this because ....

I cannot reproduce the issue so it is difficult to find out exactly what is causing it. However, not sure whether or not this is just a coincidence but another problem I encountered on the same run seems to be that the
Date close = standardDateFormat.parse(accountDate);
seemed to get completely mixed up between the threads. So there could be a threading issue but I'm not sure why!!
standardDateFormat is a private instance level variable which does not change. A constant is used to set the date format.
accountDate is a local variable.

When I reran the program with the exact same data a few hours later it was inserted correctly this time. No change was made to the program in the meantime.

Many Thanks
Hi,

I have a few things I want to clarify about synchronization and threads:

1. If a method in an object is synchronized. My understanding is that only one thread can access this method for a particular instance of the object. However, a different thread can also access the same synchronized method in a DIFFERNT INSTANCE of the same object.
Is this correct? I am pretty sure it is since locks are at the object instance level and both instances of the same object would have separate locks. Just want to make sure though.

2.Is there any way to check if a thread is in a waiting state?

Many Thanks
Hi,

I did the SCJP 1.4 exam a few months ago and used Bert Bate's and Kathy Sierra's book, which I found excellent.

I am now planning to study for the Java 1.5 upgrade exam. Is there a book specifically for the upgrade exam?

Any recommendations for study material.

Will probably get Kathy and Bert's book again but would like to hear some other thoughts.

Thanks
Hi,

This is a question about a multi-threaded program.

Imagine we have a singleton class and we call an instance of it from
2 different threads.

Both threads will now have a reference to the same object in memory.

If the singleton class has a mehod which isn't synchronized and it accepts
2 numbers and just adds them.

If we call this method from Thread 1 and pass in 2 numbers
and also call it from thread 2 and pass in 2 different numbers.
This method doesn't use any class variables and only works on the parameters passed in.

Will the 2 calls to this method always operate independently of each other?
Or would there ever be a chance where the 2 numbers passed in from thread 1 and thread 2 could get confused and add the first parameter from thread 1 to the second parameter from thread 2?

Many Thanks,
Dan
Hi,

I am writing a program which will split a file into multiple smaller files. Following this I then need to make sure that all of the data is in the split files.

Following the splitting operation I was thinking about counting the number of lines in the master file and then counting the number of lines in each of the smaller files. The sum of the lines in the smaller files should be the same as the number of lines in the master file. I'm thinking that this might take a long time and wondering if there is any quicker way of doing it.

Another possible way is the File.length method?? Should the sum of the lengths of the smaller files be the same as the length of the master file?

Would appreciate your thoughts and ideas on this.

Many Thanks
13 years ago
Hi,

I have just started to learn about the Spring Framework. However, I am finding it difficult to find good resources on the web.

I am particulary interested in Spring and JDBC.

I would like to find a book / tutorial to guide me through it with good examples.

I have had a look at the springframework.org website but it doesn't have good examples or doesn't explain it from a beginners perspective.

Any tips would be greatly appreciated.

Thanks
Hi,

I am just starting to learn EJBs and the first thing that I am trying to figure out is the relationsip between EJB specifications and Java versions.

Must EJB 2.0, EJB 2.1, EJB 3.0 be used with particular versions of Java? i.e. Java 1.3, 1.4, 1.5 etc...

If anyone could point me to a web site I would be grateful. I have had a look at Sun's web site but it isn't clear.

Many Thanks
Hey,

Just a huge thank you to everyone on the forum for all your help!!

Delighted with my result.

Kathy Sierra and Bert Bates book is excellent for preparing for this exam. Also very reassuring when Bert Bates responds to posts on this forum.

Also Sun's ePractice exams were very good.

Once again - Thanks!!
13 years ago
Hi,

I have been practising with Sun's ePractice exams lately and I came across some questions involving the Thread interrupt() method.

I presume it is relevant for SCJP 1.4 since it is on their practice exam. I am finding it difficult to understand. I searched the web to get an understanding of the method and here is my understanding:

- Call the interrupt method on a running thread does not stop the thread from running unless the thread calls one of the following methods:
- sleep()
- join()
- wait()

If the interrupt method is called before or during any of these 3 methods then an interrupted exception is thrown.

When I tested this using a program it doesn't seem to be the case though.

The following program runs without any exception:



Could anyone please help me to understand the interrupt method?

Thanks