John Sutt

Ranch Hand
+ Follow
since Mar 07, 2008
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 John Sutt

Dear all,

I know how I can use a ThreadMXBean to get a ThreadInfo object about a thread in which I can find:
- a block counter (the number of object.wait() calls), and
- the blocked time (the time spend being blocked).

But can anybody tell me how to, e.g. install an agent, that can tell me the exact objects on which the threads are blocked? It seems this might be possible somehow.

Thanks in advance,
John.
* Are you aware that you are only using your static variables height
and state in your main method? I'd suggest to have those variables
be local variables in your main method then.
* Add more comments to your code to make it easier to read what, for example,
the goals of your for-loops are. I (and you after X months) have to completely
figure it out myself. Something like:

* After you've done that, you'll quickly find out that you should not have put your
for-loop for variable k (denoted A above) within your for-loop of variable j (denoted B above).

Good luck finishing up
13 years ago

Aha, I finally found out how to get it working.
I did not tell the whole story yet. In my Ant build file,
I'd put an "index=true" which also generated an index
file together with the manifest in the meta-inf directory.

And that was the culprit, ... for some reason.
When I removed the index, suddenly the log4j classes did get found.
I guess, in case of such an index file, the classloader does not look outside
of the .jar anymore, or something like that.

Glad I got it fixed, though, and thanks for your help.

John.
13 years ago
Hi,

Thanks for pointing me to One-Jar. It looks nice, but I'd also like to know how to make this work without one-jar.
I understand now, that without special classloading code, I have to put the log4j outside of my own .jar file.

I've put log4j-1.2.14.jar and myJar.jar in the same directory. The MANIFEST file inside myJar.jar looks like this:


There is no log4j classes or jars inside myJar.jar.
Both of the following command lines produce the same error:





About Maven, I just meant that I hoped it would create a working example for me, such that I could copy it and learn from it.

John.
13 years ago
Dear all,

I'm trying to create a test .jar file, which includes other jars, I 'm using log4j-1.2.14.jar as my first test,
but getting the manifest file right (or something else?...) is driving me a bit nuts.

Now I'm using Maven, because I hoped it would do some magic and teach me how to do it right, but I ran
into the same problem as when I tried to do what I want manually.

My jar has the following structure:


App.class is the trivial Maven Hello world example, and I added a simple log.debug call to it with log4j. Note that this application works perfectly fine without packaging it into a jar.
The MANIFEST.MF file inside the jar looks like this:



Now, if a run "java -jar myJarFile.jar" I get the following error:


Why can't it find the log4j jar file ??? When I removed the lib/ from Classs-path and copied the log4j jar file to its parent directory, it also did not work with the same error.

Thanks in advance,
John.
13 years ago
Perfect! That works fine.

I understand your remark about Youtube and others, but in my case, I want it like this because I want the
user to be able to position the movie at a fraction of a second, which is not normally required.
So if a movie takes longer than 5 minutes, I would have lost some precision. Now maybe I can get the
minimum/maximum to change even while dragging the knob. And if I can tune that nicely, this will
be exactly what I want.

Thank you.
13 years ago
Dear all,

The code below is an example of how I want to include a movie-like timeline component in my application.
I thought the easiest would be to make use of a JSlider. But somehow, I need to adjust the maximum/minimum
of the JSlider when the user is dragging the handle. I tried to simplify this a little bit, by only changing the
minimum/maximum when the user drags the knob to the min or max.

However, the way I make use of the ChangeListener now results in a StackOverflow. The single System.out.prinln
statement I've included shows that the current value grows along with the maximum value, even though I've tried
to reset it after the maximum is increased.

Does somebody know how to fix this?
Thanks!

13 years ago
Aha!
The following does seem to work...



I wonder though, why the following, which I also tried, did not work then?



Thanks.
13 years ago
Dear all,

In the root of my project I have a "resources" folder which, among other things, has a few .properties files.
These files are moved into the root of the .jar file, which I export from this project.

In my code, i read these properties as follows:


I'm not using the following, because, if I understand correctly, this searches relative to the MyClass class,
and hence will not find the file in the root of the .jar file.


Anyways, both of the above URLs were null when started with Java Web Start. I decided to print the classpath,
like this:

The result was


I was suprised not to see my myJar.jar file in here. Is that the reason it fails? And how can I make sure myJar.jar file is in the classpath?

This is in my .jnlp file:



I thought that would be enough to put myJar.jar in the classpath, but apparantly not?
Hope somebody can help me,
John.
13 years ago
Hi Eugenio,

Thanks for your reply.
I will certainly have a look at it, maybe I can find out how to do it by looking at its source.

It's for learning purposes though, so I'd like to figure out how to get it working by only using
JTable.

John.
13 years ago
Dear Ranchers,

I have extended JTable with a table class that makes use of both a rowsorter (CustomTableSorter) as well
as a custom row filter (CustomRowFilter).
The problem I'm having is that, if the filter is changed (other rows are being displayed, more or less rows possible),
the sorting should be re-done.

I know the tableChanged method is called after the filter is changed - I verified this.
However, although setRowSorter(sorter) below is also executed, the sorting is often still not correct.

I guess I have to do more to make the JTable re-do its sorting (using the installed row sorter),
but what method should I call for that?

Thanks for any help.

13 years ago
I tested it now with the below program.
In case the JTextField tf is static, it did not show up in the second JFrame.
If you remove the "static", it works fine.

Hi Leandro,

I tend to disagree with you.

Making the variables static will only make sure that the program does not work correctly if the
GridBag2 class is instantiated multiple times.
For example, the txtName textfield probably is editable by the user. You don't want this to be
static!

(If you really want to enforce there is a single instance at most, you could use the Singleton pattern.)

I would make none of those variables static.
Is it much work to port Android applications to iPhone,
or is this easy?
I can imagine many developers make their applications
available on both, is that true?
(I've made an application for the G1, and I'm considering to port it.)
13 years ago
If MS SQL 2005 is configured to do replication, it adds an additional column named msrepl_tran_version to each table.
This column breaks some of my code, for instance:
1) Hibernate intelligently discovers some tables are link tables (if that is the correct English term). Say I have Table A and Table B,
and link table AB has only A and B's private keys. Now, Hibernate adds a set of C's to class A, and I can program a.getCs().
After the msrepl_tran version column is added, if I reverse-engineer again, Hiberate suddenly does not consider AB to be a link table anymore.
2) I have some code that creates new A's. I use getHibernateTemplate().saveOrUpdate(a) to store these.
This fails because the msrepl_tran_version has a NOT NULL constraint.

Is it possible to completely ignore this msrepl_tran_version column?
I have tried things like this:


but this does not seem to work, the msreplTranVersion property is still there in the Mytab pojo.

Has anybody had this problem before and/or can give me some advice?
Thanks in advance,
John.