java

How to convert an address from IPv4 to IPv6

Is this possible? How can you convert an ipv4 to an ipv6 address? a few example from here: 0.0.0.0 -> :: 127.0.0.1 -> ::1 I'm searching a solution in Java. Thanks, ...

Is it possible in Java to access private fields via reflection

Is it possible in Java to access private field str via reflection? For example to get value of this field. class Test { private String str; public void setStr(String value) { str = value; } } ...

Java: Interview questions for software tester?

These days I have an interview for the position: Software Testing Engineer. Any ideas what questions might pop to the interview? Any tips? ...

Testing: is there a framework allowing embedding Tomcat to simulate request/response cycles without involving HTTP?

For automated functional testing purposes, I would like to run a servlet container from my test driver without actually issuing HTTP requests over the network. The main goal is to test fairly elaborate conditions of servlet filtering, forwarding, and includes. I would like a system that embeds the servlet container in a way that: does...

Locking and unlocking files using the java API

One of our clients is using some Novel security software that sometimes locks some .class files that our software creates. This causes some nasty problems for them when this occurs and I am trying to research a workaround that we could add to our error handling to address this problem when it comes up. I am wondering are there any call...

expose JAXB generated Class as WSDL web service

I have a bunch of very simple functions. Each function has one input and one output. OutputType function func(InputType); The types of input/output are defined in xsd schema and generated into java classes with JAXB/XJC. Now I want to expose those functions as WSDL Web service running on Geronimo. I just took a look at Axis/WSDL2J...

Execute native code via JNI/DLL or EXE?

We have a native app that we can access via JNI->DLL or by invoking an EXE with command line parameters. Which would be the best approach? We will be invoking this method about 100 times a day. Performance isn't super important. This native app was developed by a group outside of our company so we are not too familiar with the code (...

how to create a file in Java only if one doesn't already exist?

I'm trying to implement the following operation in Java and am not sure how: /* * write data (Data is defined in my package) * to a file only if it does not exist, return success */ boolean writeData(File f, Data d) { FileOutputStream fos = null; try { fos = atomicCreateFile(f); if (fos != null) {...

Java: Socket close connection and ObjectInputStream

Hi, My code looks like this, this is Server code (Runnable) public void run() { while (true) { try { System.out.println("Waiting for client..."); this.socket = serverSocket.accept(); System.out.println("Client accepted"); while (true) { readCommand(); ...

Java Desktop.open(File f) reference file within JAR?

It is possible to for Desktop.open(File f) to reference a file located within a JAR? I tried using ClassLoader.getResource(String s), converting it to a URI, then creating a File from it. But this results in IllegalArgumentException: URI is not hierarchical. URL url = ClassLoader.getSystemClassLoader().getResource(...); System.out.prin...

Validate JList Before Selection Occur

Currently, I have a JList listen to list selection listener. private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { // When the user release the mouse button and completes the selection, // getValueIsAdjusting() becomes false if (evt.getValueIsAdjusting()) { /* In certain situat...

I want to make a "Web 2.0" application without using JavaScript directly. [Details Inside]

I'm a full time Java developer of around 4 years, professionally. I'm a GWT fanatic. I love Java. Here's the problem: In my free time I often fall victim to the verbosity of my favorite tools for doing "heavy" development. I also often fall into the trap of obsessively engineering my software. I'll end up with the most beautiful un...

How do I figure out if a column size is in bytes or characters from the column metadata?

I am working on some software that has to create dummy entries in various databases (Oracle, DB2, SQLServer) temporarily. Every column in the the row is filled with random data. The code uses java.sql.DataBaseMetaData class in java to get the COLUMN_SIZE attribute to figure out how large of a random string to store in the VARCHAR2 and ...

Use JNI instead of JNA to call native code?

JNA seems a fair bit easier to use to call native code compared to JNI. In what cases would you use JNI over JNA? ...

WSDL PolicyReference to an external file

I'm getting some errors when I try to deploy a web service generated using CXF's wsdl2java to generate the Java code from a WSDL file. I've managed to trace the error down to a NullPointerException being thrown by Apache Neethi when I tries to normalize a PolicyReference. The policy reference is defined in an external XML file (a lot o...

What is the best way to validate XML w.r.t XSD using Free XML Validator ?

Hi, I need to validate XML against XSD and so what are free XML Validator available out there that could be useful for my task. Thanks. ...

What is best approach for Storing data into MySQL after Parsing XML file using SAX Parser ?

Hi, I have student.xml file and am parsing this file using SAX Parser and now I need to store data into MySQL Database and so what approach is recommended. Code: package sax; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.SAXExceptio...

What apps have nifty maven poms and are good as examples of maven capabilites

I'm looking for applications that have "rich" maven pom(s) and can show lot of maven capabilities(plugins). These applications are needed as showcase examples - how fast and how many this can be done with maven and appropriate set of plugins. There are no constraint to technology or application type - it must be opensorce and easy to bu...

Spring map definition

What's the best way to create a bean for a HashMap<Class,String>? Specifically, do I need to explicitly create a Class bean for the key or is the class name enough? ...

Java or Django for Liferay?

Hi, I would like to get an opinion what language is better to use with LifeRay. I would like to build some app that I would like to integrate with LifeRay. What language do you suggest would I learn first? Java? - A friend suggested that Java and LifeRay goes well. Django? - I recently new this and seen the overview I find this pretty...