java

Java Concurrent and Parallel GC

This article here suggest to use -XX:+UseParNewGC 'To enable a parallel young generation GC with the concurrent GC'. My confusion is that to enable both parallel and concurrent gc do I just gotta use -XX:+UseParNewGC or do i gotta use both -XX:+UseParNewGC and -XX:+UseConcMarkSweepGC PS i am using jvm 6 ...

Getting started with writing a Java tool - Revisiting Java

I'm in a bit of an odd position. I've already decided I'm going to use Java to write a particular tool I need, and I used to know Java decently well enough to create basic applets and applications. Problem is, now that I'm revisiting it, I've forgotten a ton of what I used to know (same story with my other web technology questions). U...

printable char in java

Does anyone knows how to detect printable characters in java? After a while ( trial/error ) I get to this method: public boolean isPrintableChar( char c ) { Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); return (!Character.isISOControl(c)) && c != KeyEvent.CHAR_UNDEFINED && ...

Java Application/Class Design - How do accessors in Java work?

How do I write the getDB() function and use it properly? Here is a code snippet of my App Object: public class MyApp extends UiApplication { private static PersistentObject m_oStore; private static MyBigObjectOfStorage m_oDB; static { store = PersistentStore.getPersistentObject(0xa1a569278238dad2L); } pub...

How do I "require" a neighbour class in Java?

In Ruby I have often written a number of small classes, and had a main class organize the little guys to get work done. I do this by writing require "converter.rb" require "screenFixer.rb" . . . at the top of the main class. How do I do this in Java? Is it "import?" Also, could someone please come up with a better title for this que...

Performance question: Fastest way to convert hexadecimal char to its number value in Java?

I want to convert from char representing a hexadecimal value (in upper or lower case) to byte, like '0'->0, '1' -> 1, 'A' -> 10, 'a' -> 10, 'f' -> 15 etc... I will be calling this method extremely often, so performance is important. Is there a faster way than to use a pre-initialized HashMap<Character,Byte> to get the value from? Ans...

How do you add tests for multi threaded support?

I have a Java service which now will execute in a batch mode. Multi threaded support is added to the service so for every batch request a thread pool will be dedicated to execute the batch. The question is how do I test this? I have functional tests that pass under the threaded version of the service but, somehow, I feel there must be an...

Illegal attempt to associate a collection with two open sessions

Hi all, I'm trying to add a pojo to a collection in another pojo. I'm sure I'm making a really stupid mistake somewhere along the lines but I can't figure out how to solve it. I have a pojo LookupTable which contains a list of Column's: public class LookupTable { private long id; // More properties go here... private List<Column...

xdoclet vs xdoclet2 ?

Hi all, I'm updating an old project & my version of xdoclet complains about my Java 1.5 annontations (ArrayList data = ....) when parsing for Hibernate (hibernate3) tags. So my question is this... Is there a fix for Xdoclet 1.2.3, or should I look to move to Xdoclet2? I've already started moving some of the code over, but xdoclet2 do...

How does the SQL Server JDBC Trusted Connection Authentication work?

How does the SQL Server JDBC Trusted Connection Authentication work? (ie how does the trusted connection authenticate the logged in AD user in such a transparent and elegant fashion and how can I implement a similar authentication solution for my client-server applications in Java without a database connection or any use of the existing ...

Embedding Flash / Flex component into Java app

I'm working on some Flex spike in my company. We are basically evaluating different scenarios etc. What solution would you recommend for embedding Flex components into Java app? Flex <-> Java communication is not (yet...) an issue, just embedding swf into JFrame. ...

JTidy Node.findBody() — How to use?

Hello, I'm trying to do XHTML DOM parsing with JTidy, and it seems to be rather counterintuitive task. In particular, there's a method to parse HTML: Node Tidy.parse(Reader, Writer) And to get the <body /> of that Node, I assume, I should use Node Node.findBody(TagTable) Where should I get an instance of that TagTable? (Constructor...

How should I implement a dropdown box which contains a list of items which need to be shown in different languages?

I'm trying to design a form which contains a dropdown box containing a list of grocery item choices. What criteria should I look at when trying to decide on whether to use a java enum or a lookup table? Also, I will need to plan ahead for i18n support for the dropdown strings. ...

Is it okay to update a Java web application by replacing just single class files?

Sometimes, when we're doing small changes to our web apps, e.g. bug fixes, we don't build a whole new WAR-file each time, but merely replace just the affected class files in the exploded web app directory under WEB-INF/classes and restart the app. Is that okay? ...

Hibernate: hbm2ddl.auto=update in production?

Is it okay to run Hibernate applications configured with hbm2ddl.auto=update to update the database schema in a production environment? ...

Rest clients for Java?

With JSR 311 and it's implementations we have a powerful standard for exposing Java objects via Rest. However on the client side there seems to be something missing that is comparable to Apache Axis for SOAP - something that hides the web service and marshals the data transparently back to Java objects. How do you create Java RESTful cl...

How would you implement an LRU cache in Java 6?

Please don't say EHCache or OSCache, etc. Assume for purposes of this question that I want to implement my own using just the SDK (learning by doing). Given that the cache will be used in a multithreaded environment, which datastructures would you use? I've already implemented one using LinkedHashMap and Collections#synchronizedMap, but ...

SWT - OS agnostic way to get monospaced font

Is there a way in SWT to get a monospaced font simply, that works across various operating systems? For example. this works on Linux, but not Windows: Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE); or do I need to have a method that tries loading varying fonts (Consolas, Terminal, Monaco, Mono) until one isn't nu...

What code highlighting libs are there for Java?

easy to bundle, few dependencies, easy to use ...

Creation timestamp and last update timestamp with Hibernate and MySQL

For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated. How would you design this? What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)? Will the data types be timezone-aware? What data types would you use in Java (Date,...