java

How to Deploy my Open Source Projects using Maven's Central Repository?

Is there anything I could do to get my own open source stuff into Maven's Central repository? I've wondered many times how I could get my own projects into Maven's Central repository. I was asking this myself, especially as I've seen some well known projects hosting their own repository, requiring users to add dependency and repository....

Have something loaded only when JList item is visibile

Hello, i'm implementing a Jlist populated with a lot of elements. Each element corresponds to a image so i'd like to show a resized preview of them inside each row of the list. I've implemented a custom ImageCellRenderer extending the Jlabel and on getListCellRendererComponent i create the thumbnail if there'snt any for that element. Eac...

Images will not work in a .jar file

When a .jar of an application is created, the images in the application no longer appear. An example of our code for loading images is: ImageIcon placeHolder = new ImageIcon(src\Cards\hidden.png); We have no idea why this is happening. The application runs as expected if we do not compress it to a .jar; as a .jar, the images simply dis...

Performance issue using <s:bean/> tag

I seem to be having a performance issue in some of my Struts 2 actions. On several of my pages, I render a couple of drop down tags in my output page. I populate the drop down tags by instantiating an tag and invoking the methods in the bean to call an EJB service and populating a collection property from the results. The collection is...

how to translate this (see the code below )to C# ?

how to translate this to C# import java.io.*; import java.net.*; class SimpleServer { private static SimpleServer server; ServerSocket socket; Socket incoming; BufferedReader readerIn; PrintStream printOut; public static void main(String[] args) { int port = 8080; try { port = Integer.parseInt(arg...

Tool to deobfuscate Java codes

Is there a tool to deobfuscate java obfuscated codes? The codes is extracted from a compiled class but they are obfuscated and non-readable. ...

RSA Encryption: Java to PHP

I'm trying to implement RSA Encryption in both Java and PHP, but I can't seem to get PHP to recognize my Java public/private keys. Here is the java code to Encode/Decode the Public and Private Keys: public static byte[] EncodePublicKey(PublicKey _publickey) throws Exception { return _publickey.getEncoded(); } public static PublicKe...

Why aren't all the entries going in the file?

In the following program, loop is iterating 1000 times, and I am writing all the entries in a file using a FileWriter, but unfortunately programs ends up writing only 510(sometimes 415, sometimes 692, always less then 1000) entries in the file, but loop is iterating 1000 times. import java.io.* ; import java.util.*; public class DemoWr...

Can you provide information or links that discuss using resource state over session or DB state?

There is a talk here by Stefan Tilkov, where he is describing REST architecture at its core. I haven't watched all of it, but in the portion where he talks about the 5 Principles of REST (slides 12-19) he mentions maintaining state through the resource (i.e. -- the URI). His example is a shopping cart. Usually the state of your shopping ...

Resin's `pomegranate' - auto-magical-loading maven jar dependencies for a project - but how to generate jars with pom.xml for them?

Hi. Resin java server has a neat feature they call pomegranate ( http://www.caucho.com/projects/pomegranate/ ) which allows to just put various jar dependencies in server's directory (project-jars/) and then it loads them for a web-app from its pom.xml file. Question is: how should I put the jars to resin's project-jars ? (just copying...

Serialising and immutable objects

I have a class which is intended for immutable use, hence I would like to label all the fields final. However the class is serialized and deserialized to send over the network. For this to work an empty constructor is required. This prevents me creating the final fields. I'm sure this is a fairly common problem but I can't find a solut...

Ant build script executing <sql> task using java code

Any idea, why none of the debugging comments are printed once after executing the ANT build script's SQL task via java code? The java class to execute the sql in build scirpt is public class AntRunnerTest { private Project project; public void executeTask(String taskName) { try { project = new Project(); project.i...

Downloading large files via web service in Java

I have a web application sitting out there that is a repository for files. This web application provides web services that allow clients to search the repository and download any of the attachments via SOAP. Currently I have tried to use Spring-WS 1.5.8 with MTOM to send the attachment to the client, but I keep getting out of memory err...

Time Synchronization Code

I'm writing some code that needs to know how much out of sync the client and the single server's time are. I'm trying to do it by creating a temp file on a SMB share hosted on the server and reading of its last modified time. I thought (maybe incorrectly) that the timestamp would be generated by the server and not the client. since it s...

Turning text into executable statements

This is a question out of curiousity for java or c++, I wanted to ask if it is possible to turn any text input into some executable statements? For example say I have a text file with info like: "class: Abc, Param: 32" Now say in C++ or Java I want to read that file and do something like: new Abc(32); How would I do that? Its easy...

Missing something HashSet duplicates

Ok Apparently I'm missing something here. I cannot seem to get a HashSet to work. I'd imagine it's probably something easy I'm just overlooking. import testing.Subclass; import java.util.HashSet; public class tester{ public static void main(String[] args) throws Exception{ HashSet<Subclass> set = new HashSet<Subclass>(); set....

how to set UTF8 lang on Tomcat/java running on Mac OS 10.5.8?

I'm running Tomcat6 locally on Mac OS 10.5.8. Our staging and production servers have setup an environment variable of: LANG=en_US.UTF-8 Stage and production run on CentOS and read this value in when java and Tomcat starts up. However, it doesn't appear that java is reading this value and is defaulting to en_US_ISO_85591. On my local ...

Setting up a Restful POST request using xml

Hi, I'm working on setting up a RESTful request for the application I'm working on and I wanted to use xml as the request in the uri instead of allowing the client to supply the parameters in the URI itself. I'm looking to have the URI like so: someurl/service/request instead of: someurl/service/request?id={id}&name={name} I have...

Accessing look and feel default icons?

I want to change the selected icon for a JCheckbox to a different icon, let's say for example the disabled selected icon for a JCheckbox. How can I get the disabled selected icon from the UIManager? I tried UIManager.getIcon("CheckBoxUI.disabledSelectedIcon"); Is that the wrong icon property name or is that just the wrong way to get ...

Dynamic method return types in java

The following code does exactly what I want it to, but I am curious if there is a better way of going about it. This would be so much easier if Interfaces allowed static methods, or if Java methods could be generalized/parameterized to the extent they can in C#. I would much rather substitute the parameter "Class<TParsedClass> c" for "C...