java

Reverse (parse the output) of Arrays.toString(int[])

Is there in the JDK or Jakarta Commons (or anywhere else) a method that can parse the output of Arrays.toString, at least for integer arrays? int[] i = fromString(Arrays.toString(new int[] { 1, 2, 3} ); ...

[JAVA] Make application run in its own directory

I'm trying to get an application (a game) to start with a Java script. There is a long explanation behind why, so I'll skip that part. The game won't run unless it is executed from its own directory, IE: Just telling Java to launch the EXE gives errors within the game. It must be launched from its directory. I've Googled for hours over...

How does VS2008+ReSharper compare to IntelliJ IDEA?

I used to be a Java user, but I moved into 100% .NET 4 years ago. Having grown accustomed to ReSharper and all the commands it offers, how does it compare to IntelliJ? Both being from JetBrains, I'd imagine they are close - but I haven't used it. (I know I can do that and answer myself, but YMMV.) Thanks; ...

how do I convert my java files into an application?

I coded up 4 .java files. The thing is that I can only execute my .java files from my IDE, how do I execute the .class files like an application? I study at uni, and I was told that Java is platform independent. Any tutorial/book recommendations would be highly appreciated. Thanks ...

SQLException: fetched column value was truncated when executing while (rs.getNext())

I have a program that pulls a large dataset from Oracle 10g (10.2.0.3) using a fairly-straightforward query. You could almost call the query/logic an "export" of sorts in that it selects the columns from a table with a minimal where clause (i.e., it returns most of, if not all, the rows). The [Java] code is boilerplate that we have all...

Should I implement source control for j2ee application server configuration files?

For a typical J2EE web application, the datasource connection settings are stored as part of the application server configuration. Is there a way to version control these configuration details? I want more control on the datasource and other application server config changes. What is the standard practice for doing this? ...

Java Wrapper equality test

public class WrapperTest { public static void main(String[] args) { Integer i = 100; Integer j = 100; if(i == j) System.out.println("same"); else System.out.println("not same"); } } The above code gives the output of "same" when run, however if we change the value of i and j to 1000 the ...

How can I create a Java/Swing text component that is both styled and has a custom font?

How can I create a Java/Swing text component that is both styled and has a custom font? I want to highlight a small portion of the text in red, but at the same time use a custom (embedded via Font.createFont) font. JLabel accepts HTML text, which allows me to highlight a portion of the text, but it ignores font settings when rendering HT...

How can I access spreadsheets in the open document format (.ods) with java?

I want to read, write and create Spreadsheets in the Open Document Format with Java. And I want the resulting Java-program running on a computer without OpenOffice.org or other ODS-capable programs installed. Exists a library to access this format? ...

How to cache a WSDL with Java-WS

I've created an app that interacts with a SOAP service using java WS. I generate classes and manage the WSDL using the built in netbeans functions. Every time I run the application, it has to download the WSDL and parse it again. The WSDL is frozen at each version so I don't think this is necessary. I've tried to reference it as a lo...

Code to utilize memory more than 70%

Please tell me C++/Java code which utilize memory more than 70% . For Example we have 3 Virtual machine and in memory resources we want to test the memory utilization as per memory resources allocated by user. ...

In Java how would you write the equivalent of Iterable which could throw exceptions?

In java a class can implement Iterable which lets you use the foreach() statement and the iteration syntatic sugar: for(T t:ts) ... However, this does not allow you to throw exceptions on the construction for an Iterator. If you were iterating off a network, file, database etc it would be nice to be able to throw exceptions. Obvious ...

How to cause soft references to be cleared in Java?

I have a cache which has soft references to the cached objects. I am trying to write a functional test for behavior of classes which use the cache specifically for what happens when the cached objects are cleared. The problem is: I can't seem to reliably get the soft references to be cleared. Simply using up a bunch of memory doesn't do...

sun.java2d.loops.ProcessPath$Point

I am profiling an application suddenly using a lot of memory, and i am getting this: sun.java2d.loops.ProcessPath$Point As being allocated almost 11.000.000 times. What is it, and is there a solution to this? ...

use of system.exit(0)

public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x); System.exit(0); } } In the above code System.exit(0) is used to stop the program. What argument does that method take? Why do we gave it as 0. Can anyone explain the concept?Thanks. ...

How to generate a hash value in J2ME?

How can I generate hash value for a byte array, in J2ME? It doesn't have to be very very secure but it should be fast. ...

Putting JComboBox into JTable

Hi, I want to put individual JComboBoxes into each cells of a JTable. ie. The JComboBox content is not identical for each cell. I basically would like to be able to just call the following code to add a row of JComboBox into the JTable. Anyone has any idea? Thanks JComboBox cb1 = new JComboBox(...); JComboBox cb2 = new JComboBox(...)...

Java Applets loading at snail's pace

I have a Java Applet application ( achart) on my php Webpage ... Problem here is the Java Applet takes more time to load ... I am thinking of replacing these applets with some similar technology but fast ... I am counting on Ajax... what are my other options ... ? ...

How to throttle login attemps in Java webapp?

I want to implement an efficient mechanism to throttle login attemps in my Java web application, to prevent brute-force attacks on user accounts. Jeff explained the why, but not the how. Simon Willison showed an implementation in Python for Django: That doesn't really help me along as I can't use memcached nor Django. Porting his ide...

How to return multiple objects from a Java method?

I want to return two objects from a java method and was wondering what could be a good way of doing so? The possible ways I can think of are: return a HashMap (since the two Objects are related) or return an ArrayList of Object objects. To be more precise, the two objects I want to return are (a) List of objects and (b) comma separated...