java

Why are System.out/err implemented as Byte Streams in Java?

I was having a look at this tutorial at Sun on command line I/O. It stated that: You might expect the Standard Streams to be character streams, but, for historical reasons, they are byte streams. System.out and System.err are defined as PrintStream objects. Although it is technically a byte stream, PrintStream utilizes an...

AlmostEqual2sComplement or BigDecimal Scaling

Using Java: The more I read on floating point value comparison, the more I get lost. In case of currency which is usually gets rounded off, what whoule you prefer..using Epsilon or a Big Decimal comparison with scaling? For instance, your data would range from 0.00 - 49,999.99? ...

exit batch file using java code

Hi, I am having the sample code like this. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author padmaja */ import java.io.*; class Test{ public static void main(String arg[]){ try{ String command = "cmd /C start C:/excel.bat"; Runtime rt = Runtime.get...

Java: Double Value Comparison

Do we need to be careful when comparing a double value against zero? if ( someAmount <= 0){ ..... } ...

accessing command-line arguments from OSGi bundle

I have an application that runs as a collection of OSGi bundles. I start it using a very small wrapper that embeds the Felix framework. The necessity of that wrapper irks me a little, as does the fact that it depends on Felix (whereas the application itself could run just as well in, say, Equinox), so I want to get rid of it, and use the...

Sockets: Discover port availability using Java

How to programmatically find availability of a port in a given machine using java?i.e given a port number whther it is already being used . ...

How to sample multi-channel sound input in Java

I realised this might be relatively niche, but maybe that's why this is good to ask anyway. I'm looking at a hardware multiple input recording console (such as the Alesis IO 26) to take in an Adat lightpipe 8 channel input to do signal processing. As I have yet to acquire the device and need to work out whether this is feasible (budgetar...

RCP + JNLP\WebStart App will not start

I've followed this example: RCP+JavaWS but the app just briefly comes up and goes away. I've turned the console on and it quickly goes away too. I've tried adding: -console, -consoleLog, and -noExit to my application-desc args and I have searched my Application Data dir to no avail. Does anyone have any ideas where I could look to find...

OS recommendation to run Java Swing App on very basic hardware

We have a Client/Server POS application. For the Java Swing Client, we are evaluating a system with very basic hardware Celeron 300 CPU expandable to PIII 1.2 Ghz. 810 E motherboard. 64 MB SD RAM, DIMM's, expandable to 256 MB. 4.3 GB HDD expandable to 80 GB and above. 10 / 100, ethernet / lan card for connecting to server, broadband -...

How to rename a file name without change its type?

Hi to all, I have doubt in renaming java files... My application has to rename the incoming file which is mdb,dbf,xls,xml,etc. format. I used the following source code. eg: String filename = "D:/sample.mdb"; File filediriden = new File(filename); String[] filetype = filename.split("\\."); System.out.println("Filetype :"+filetype[1]); ...

Transaction rollback and web services

Given an example of calling two web services methods from a session bean, what if an exception is thrown between the calls to two methods? In the case of not calling the web services the transaction will rollback and no harm done. However, the web service will not rollback. Of course, even with a single web service there is a problem. Wh...

HashMap intialization parameters (load / initialcapacity)

What values should I pass to create an efficient HashMap / HashMap based structures for N items? In an ArrayList, the efficient number is N (N already assumes future grow). What should be the parameters for a HashMap? ((int)(N * 0.75d), 0.75d)? more? less? What is the effect of changing the load factor? ...

Spring context.xml and Set.contains()

Spring: In my context.xml, I have: <util:set id="someIDs" set-class="java.util.HashSet" value-type="java.lang.String"> <value>"W000000001"</value> <value>"W000000003"</value> <value>"W000000009"</value> </util:set> In my Java bean, the implementation is: private Set<String> someSet = ComUtiliti...

java.util.ConcurrentLinkedQueue

I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the blurb from the javadoc for the class. An unbounded thread-safe queue based on linked nodes. A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. This queue does not permit null element...

Is a service principal name (SPN) bound to a specific machine?

At the moment I am getting a KrbException: Integrity check on decrypted field failed (31) with my GSS demo application (on the server side). Now I am looking for the reason for this. I have the suspicion, that it comes from the fact that the client and the server application run on the same machine (localhost) and/or the SPN was genera...

Universal document format converter

I am looking to convert any format to/from HTML. I'd like to support DOC, DOCX, PDF, ODT, RDF, DocBook, and TXT. I have found lots of format-to-format conversion utilities, but for convenience of implementation, a single tool is best. This will also make it easier to add new formats as the vendor or open-source project expands the lib...

How to quickly modify compiled java classes behaviour with aspectJ

How to use aspectJ to add functionality temporarily to some java application? Something like creating the aspect, compiling with ajc, using java command with some extra switch to apply aspect? ...

Jasper reports counting pages depending on group

The problem is like this. The report page numbers that are displayed on the page should not be dependent on the current but on the group page. Let me explain: I have a report with 2 groups that has 4 pages, each group on two pages, and what I need to do is the following: group 1 page 1: should be: 1/2 -> current: 1/4 group 1 page 2:...

Can Applet open a new HTML window *and* bypass popup blocker?

Our java applet needs to open a new htm page to web browser but popup blocker seem to block this code: try { AppletContext a = getAppletContext(); URL url = new URL(link); a.showDocument(url,"_blank"); } can you use somehow live javascript to open a window instead? ...

Why am I unable to generate client side code in web services 'Hello world' example?

Link is: http://people.apache.org/~ruchithf/hw-axis2/. Command line is: javac -extdirs d:\lib\ D:\stub\src\org\apache\ws\axis2*.java -d d:\clientcode\ The Error is: C:\Program Files\Java\jdk1.6.0\bin>javac -extdirs d:\lib\ D:\stub\src\org\apache \ws\axis2\*.java -d d:\clientcode\ D:\stub\src\org\apache\ws\axis2\Client.java:3: cannot f...