java

How do I set environment variables from Java?

How do I set environment variables from Java? I see that I can do this for subprocesses using ProcessBuilder. I have several subprocesses to start, though, so I'd rather modify the current process's environment and let the subprocesses inherit it. There's a System.getenv(String) for getting a single environment variable. I can also g...

Tomcat context.xml files, is there a hiearchy?

I am trying to use symbolic links in one of the applications I have running on Tomcat5. Thanks to some help from another StackOverflow question I was able to do it by creating a context.xml file in /...myapplication/META-INF/context.xml I am now trying to implement this on a production server. However, there are other applications ...

Problems in ClassLoaders for Long running Tomcat process

Hi, We have hosted our web applications on Tomcat 6.0.18 and experienced the following problem: There are two web apps WebApp1 and WebApp2, both are same system but of different versions. Now the problem is when the tomcat has been running for a week or longer time then sometimes system gives NoClassDefFoundError ! also we got some s...

Truststore and Keystore Definitions

In Java, what's the difference between a keystore and a truststore? ...

Extracting Information from websites

Not every website exposes their data well, with XML feeds, APIs, etc How could I go about extracting information from a website? For example: ... <div> <div> <span id="important-data">information here</span> </div> </div> ... I come from a background of Java programming and coding with Apache XMLBeans. Is there anything simil...

displaytag: suppress zeros in HTML table

Hi, I have a HTML table that's generated in a JSP by the displaytag tag library. I would like to suppress any zeros that appear in the table, i.e. they should be replaced by a blank cell. Is there any straightforward way to achieve this? Cheers, Don ...

Null object design pattern question

I recently watched this youtube tutorial on the Null Object design pattern. Even though there were some errors in it: such as the NullCar that doesn't do anything creates an infinite loop, the concept was well explained. My question is, what do you do when the objects that can be null have getters, and are used in your code? How do you k...

Java Serialization 1.4 vs 1.6

I have one java program that has to be compiled as 1.4, and another program that could be anything (so, 1.4 or 1.6), and the two need to pass serialized objects back and forth. If I define a serializable class in a place where both programs can see it, will java's serialization still work, or do I need 1.6-1.6 or 1.4-1.4 only? ...

Automatic entity mapping similar to O/R-mapping with JSF?

With JPA I do not need to code the SQL for every new attribute as the o/r-mapping is being done automatically. As I am new to JSF, i am wondering whether there is a similar possiblity with JSF? I do not want to add new code to a jsf datatable every time I change something at the corresponding entity. ...

Null \u0000 in Java String?

Are there any good reasons not to use \u0000 as a delimiter within a Java String? I would be encoding and decoding the string myself. This is for saving a list of user-inputted (I'm expecting input to be typed?) strings to an Eclipse preference and reading it back. The list may be variable size so I don't think I can save each item to i...

JPA/Hibernate mapping to store months and days-of-months

I have following POJOs: class Month { long id; String description; List<Day> days; // always contains 29, 30 or 31 elements } class Day { byte nr; // possible values are 1-31 String info; } Is there a way to store these objects into following DB structure using JPA+Hibernate: Table MONTHS: id;description; Table...

Security considerations when hosting signed jars

What are the security implications for hosting signed jars on the internet? As I understand jar signing, once a user choose to auto-accept a certificate, it doesn't matter if the signed jar came from your domain, linked from another domain or hosted on another domain. For example, Sun uses this method to give applets OpenGL support, by ...

Are the Swing LayoutManagers adequate?

I just had to add a checkbox to an application that was written before I got here, and it was way more difficult than it had to be because the app uses some third-party LayoutManager that attempts to do pseudo-absolute, gridlike positioning. The API was terrible, it takes position-designating strings that are comma-delimited lists of tw...

J2ME development without Java?

I'm making my first foray into the J2ME world. I'd prefer to use a functional language to do the development. Scala used to have CLDC support, but it's no longer maintained. Bigloo seems to have disappeared. Interpreters (such as Jython) are a no-go, since J2ME apps have to be small (at least, mine has to be). I would like to know of ...

How do you test if cookies are enabled in Java/J2EE

Testing: return request.getCookies() == null; is not an appropriate way test. Is there another way? ...

What does PermGen actually stand for?

I know what PermGen is, what it's used for, why it fails, how to increase it etc. What I don't know is what PermGen actually stands for. Permanent... Gen... something? Does anyone know what PermGen actually stands for? ...

Why is Java able to store 0xff000000 as an int?

An integer's max value in Java is 2147483647, since Java integers are signed, right? 0xff000000 has a numeric value of 4278190080. Yet I see Java code like this: int ALPHA_MASK = 0xff000000; Can anyone enlighten me please? ...

How many dimensions in an array with no value

I'm a little lost (still working with Ron Jeffries's book). Here's a simple class: public class Model{ private String[] lines; public void myMethod(){ String[] newLines = new String[lines.length + 2]; for (i = 0, i <= lines.length, i++) { newLines[i] = lines[i]; } } } I have another cla...

Basic Excel currency format with Apache POI

I'm able to get cells to format as Dates, but I've been unable to get cells to format as currency... Anyone have an example of how to create a style to get this to work? My code below show the styles I'm creating... the styleDateFormat works like a champ while styleCurrencyFormat has no affect on the cell. private HSSFWorkbook wb; priv...

Generate formatted diff output in Java

Are there any libraries out there for Java that will accept two strings, and return a string with formatted output as per the *nix diff command? e.g. feed in test 1,2,3,4 test 5,6,7,8 test 9,10,11,12 test 13,14,15,16 and test 1,2,3,4 test 5,6,7,8 test 9,10,11,12,13 test 13,14,15,16 as input, and it would give you test 1,2,3,4 ...