java

How do I detect if a function is available during JNLP execution?

I have an application which really should be installed, but does work fine when deployed using JNLP. However, it would seem that some Java functions such as Runtime.exec don't work using the default security options. I would like to therefore disable UI functionality that relies upon such functions. So my question is, how do I detect a...

Best iCalendar library for Java?

I'm looking for a library to handle iCalendar data in Java. Open source, well-documented implementations with a good object model are preferred. iCal parsing capabilities are less important to me, but still nice to have. Does anyone have any recommendations? ...

How to get facet ranges in solr results?

Assume that I have a field called price for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it? I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges (say for 5 values) automatically base...

How do you get the ethernet address using Java?

I would like to retrieve the ethernet address of the network interface that is used to access a particular website. How can this be done in Java? Solution Note that the accepted solution of getHardwareAddress is only available in Java 6. There does not seem to be a solution for Java 5 aside from executing i(f|p)confing. ...

In Maven 2, how do I know from which dependency comes a transitive dependency ?

I would like to know which dependency described in my pom.xml brings a transitive dependency in my target directory. To be more precise, I have the library "poi-2.5.1-final-20040804.jar" in my WEB-INF/lib directory and I would like to know which dependency in my pom.xml brings that. ...

Why am I getting a NoClassDefFoundError in Java?

I am getting a NoClassDefFoundError when I run my Java application. How do I fix it? ...

What's the best way of unit testing private methods?

How do I use jUnit to test a class that has internal private methods? It seems bad to change the access modifier for a method just to be able to run a test. Thanks. ...

data 'security' with java and hibernate

Hi there, The system I am currently working on requires some role-based security, which is well catered for in the Java EE stack. The system intends to be a framework for business domain experts to write their code on top of. However, there is also a requirement for data 'security'. That is, what information is visible to an end user. ...

How to keep a "things done" count in a recursive algorithm in Java?

I have a recursive algorithm which steps through a string, character by character, and parses it to create a tree-like structure. I want to be able to keep track of the character index the parser is currently at (for error messages as much as anything else) but am not keen on implementing something like a tuple to handle multiple return...

Trouble using JRun to Host Java Servlets

I am deploying new versions of java servlets with JRun as the host. I am having difficulty finding good sources for information about JRun and tutorials about how to configure and manage it. After installing JRun and opening the launcher it can't start the admin server that it creates by default...so obviously I'm running into some issu...

Does C# have a way of giving me an immutable Dictionary?

Is there anything built into the core C# libraries that can give me an immutable Dictionary? Something along the lines of Java's: Collections.unmodifiableMap(myMap); And just to clarify, I am not looking to stop the keys / values themselves from being changed, just the structure of the Dictionary. I want something that fails fast ...

Prevent SWT scrolledComposite from eating part of it's children

What did I do wrong? Here is an excerpt from my code: public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); ScrolledComposite scrollBox = new ScrolledComposite(parent, SWT.V_SCROLL); scrollBox.setExpandHorizontal(true); mParent = new Composite(scrollBox, SWT.NONE); scrollBox.setContent(mParent)...

How do I fix a NoSuchMethodError?

I'm getting a NoSuchMethodError when running my Java program. What's wrong and how do I fix it? ...

Large File Download

Internet Explorer has a file download limit of 4GB (2 GB on IE6). Firefox does not have this problem (haven't tested safari yet) (More info here: http://support.microsoft.com/kb/298618) I am working on a site that will allow the user to download very large files (up to and exceeding 100GB) What is the best way to do this without using...

Changing default file structure in a Java Struts App

Hey, I have been working with Struts for some time, but for a project I am finishing I was asked to separate Templates (velocity .vm files), configs (struts.xml, persistence.xml) from main WAR file. I have all in default structure like: application |-- META-INF -- Some configs are here |-- WEB-INF ...

XML serialization in Java?

Is there a (preferably free) Java analogue of .NET's XML serialization? ...

Process ID in Java

How do I get the id of my Java process? I know there are several platform-dependent hacks, but I'm after a generic solution. ...

What are the differences between "generic" types in C++ and Java?

Java has the generic keyword and C++ provides a very strong programming model with templates. So then, what is the difference between C++ and Java generics? ...

Struct like objects in Java

Is it completely against the Java way to create struct like objects? class SomeData1 { public int x; public int y; } I can see a class with accessors and mutators being more Java like. class SomeData2 { int getX(); void setX(int x); int getY(); void setY(int y); private int x; private int y; } The ...

Virtual functions in constructors, why do languages differ?

In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered for the first time was surprised but on second thought it makes sense, if the derived constructor hasn't yet run the object is not yet a derived so how can a derived function be called? The precon...