java

This java technology stack in .net?

Hi, Having worked for Java for 7 years I'm now moving into a project in .net. The team I'm working in have recently used a technology stack that we are fairly happy with in the business layer and below: Spring for dependency injection, transaction management, security and for adding interceptors and for getting the possibility to injec...

How to get the WTSClientAddress from the java.lang.Object getClientInfo()

In one of our current web application we are using the getClientInfo() from a java.lang.Object reference in our Oracle Forms application which works great for egtting the client IP address of a system. However we recently started to use Windows Terminal Servers in our organization, and we are now having the problem with this code return...

Why use BufferedReader in this case?

What is the difference between using a BufferedReader around the StringReader in the following code vs using the StringReader only? By loading up the DOM in line 2 of both examples, it seems like the BufferedReader is not necessary? InputSource is = new InputSource(new StringReader(html)); Document dom = XMLResource.load(is).ge...

Problem showing japanese characters with java substance

For some reason, when I have japanese characters in the title bar that is themed with java substance, I am not able to display them. Instead it shows as squares. If I have no substance theme, I can see the japanese characters in the title bar just fine. I have found ways to show these characters in all other parts of my program except...

naming conventions when doing O/R mapping

I am mapping my database tables to my java objects. Generally I name my tables in the plural form in that a table holding books information is called BOOKS. The java object represents however one book and should be called Book. Similarly for AUTHORS/Author etc. On the other hand, its kind of simplistic to give the same to the domain ob...

URLConnection FileNotFoundException for non-standard HTTP port sources

I was trying to use the Apache Ant coretask Get to get a list of WSDLs generated by another team in our company. They have them hosted on a weblogic 9.x server on http://....com:7925/services/. I am able to get to the page through a browser, but the get task gives me a FileNotFoundException when trying to copy the page to a local file ...

How to get a path to a resource in a Java JAR file

I am trying to get a path to a Resource but I have had no luck. This works (both in IDE and with the JAR) but this way I can't get a path to a file, only the file contents: ClassLoader classLoader = getClass().getClassLoader(); printInputStream(classLoader.getResourceAsStream("config/netclient.p")); If i do this: ClassLoader class...

Check if a pdf file is valid using PdfBox by Apache

I am using PdfBox in Java to extract text from PDF files. Some of the input files provided are not valid and PDFTextStripper halts on these files. Is there a clean way to check if the provided file is indeed a valid PDF? ...

How to send a Class over the wire

Hi, I have the following problem: I want to send a type (java.lang.Class) over the wire and 'define' the class on the other side. I tried like that: ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(MyClass.class); and on the receiving end: ByteArrayInputS...

Test and Mock framework for Java and .NET

I'd like to know your thoughts about test/mocking frameworks that are widely used and have a good level of compatibility between Java and .NET. I mean, I want to learn those tools to use in a .NET project, but I still wanna be able to apply that knowledge in Java projects. I know there're many questions about test/mocking frameworks to...

Hibernate/JPA - annotating bean methods vs fields

I have a simple question about usage of Hibernate. I keep seeing people using JPA annotations in one of two ways by annotating the fields of a class and also by annotating the get method on the corresponding beans. My question is as follows: Is there a difference between annotating fields and bean methods with JPA annoations such as @I...

Remove "X" button in Swing JDialog

Is there a way to remove the close button ("X") from the JDialog title bar? ...

Java reflection: array of classes vs. array of parameter types

I have an object m of class Method. I invoked m.getParameterTypes() to create an array params of the method's parameters. I also have an array arr of Objects. I wanted to check if the objects in arr are of the same types as the types in params (and in the same order). What I did was to create an array classes which includes the class of ...

Calling static method on a class?

Say, I have a reference to a Class object with SomeType having a static method. Is there a way to call that method w/o instantiating SomeType first? Preferably not escaping strong typing. EDIT: OK, I've screwed up. interface Int{ void someMethod(); } class ImplOne implements Int{ public void someMethod() { // do something } } Cl...

DragAndDrop in selenium

Hi all, While using DragAndDrop function on a splitter control what I see is first it gets stuck most of the times. Also when I give the offset as +70 it moves to the position which is 70 units away from the start of the screen. What I understand is that it should move 70 units away from where it is now. Any idea why this is not workin...

Java's equivalent of Ruby's __FILE__ ?

In Ruby I frequently use File.dirname(__FILE__) to open configuration files and such. For those that don't know Ruby, this will give the location on the file system of the file it's called from. This allows me to package libraries with data and config files and open those files with relative paths. What's the Java equivalent of this? I...

Is there a way to hide the tab bar of JTabbedPane if only one tab exists?

I want a behavior similar to e.g. Firefox where the list of available tabs does only show up if at least two tabs exist. I wasn't able to find anything like that, yet. The best idea I had was changing the layout manually: in case of one component, just add that to the surrounding panel if a component is added, remove the component fr...

what eclipse GUI builder plugin do you suggest

i'm trying to create a user interface in java? what ui builder do you suggest for me to use? Thanks. ...

java chain exception

hi all i have question regarding chain exception try{ } catch(Exception e) { throw new SomeException(); } if i do like this my eclipse will prompt error at line throw new SomeException(); stating "unhandled exception" and i must put something like try{ } catch(Exception e) { try{ throw new SomeException()...

(Java) Appearing/Disappearing JLabel in a JPanel only disappears on resize

I'm working in Java, and I have a JPanel in a JFrame. In that JPanel, among other things, I have a JLabel that I want to make appear and disappear at will. I've tried setting visibility to true/false, adding and removing it from the JFrame and JPanel, and, having looked online, I tried validate()ing and revalidate()ing ad infinitum. What...