java

How to authenticate against native OS in Java and without using JNI?

My Java RCP application prompts the user for username and password upon start-up. How could I use these credentials to do authentication against the native OS without using JNI to port some C libraries? Thanks! PS. If possible, pure Java implementation without using third-party libraries will be very much preferable. ...

Java - Reading Strings and Binary from the same stream

I have a file that contains some amount of plain text at the start followed by binary content at the end. The size of the binary content is determined by some one of the plain text lines I read. I was using a BufferedReader to read the individual lines, however it exposes no methods to refer to read a byte array. The readUTF for a DataI...

split string java

duplicate: http://stackoverflow.com/questions/527595/split-string hi, i'm have string like this 200209151422010231.10408360.00502240.105090.0200209151423010231.10408360.00502289.605090.0 i want to split this 200209151422010231.10408360.00502240.105090.0 200209151423010231.10408360.00502289.605090.0 and store int Array when 0x01 ...

Possible to draw in YCbCr in Java?

Hi everyone, I've a project at the moment, in Java, which uses a filetype which is inherently in the YCbCr colorspace. Within this, there is a lot of number crunching happening behind the scenes (which I've had to code) to convert to RGB from the YCbCr values. This is done per-pixel, per-frame, at 25 frames per second... The project mu...

Reading HTML file to view in JEditorPane

Hello. I have a Java program which prints to a HTML file. Another method reads in this file and prints it to the editor pane. My problem is that the color orange doesn't work. My code is as follows: print.println("<html><p><br><font color=\"orange\">"); When I pass this html file into the editor pane all the colors are right. Red, ye...

Non-blocking UDP I/O vs blocking UDP I/O in Java

Non-blocking TCP/IP SocketChannels and Selector in NIO help me to handle many TCP/IP connections with small number of threads. But how about UDP DatagramChannels? (I must admit that I'm not very familiar with UDP.) UDP send operations don't seem to block even if the DatagramChannel is not operating in blocking mode. Is there really a...

Parallel development in Java and C#

I am maintaining two very similar schedulers - one in Java and one in C#. The C# version was originally created using JLCA and then modified by hand. The Java version has been modified quite significantly over the last few weeks by someone else (so I have to track down his changes), and I am wondering whether to reconvert it using one o...

Recommendations for migrating a legacy web app to a modern framework.

Hello all, I am currently doing some work for a company that runs a legacy web app built on Java Servlets (the system pre-dates JSP's, although they now use them when building new pages). The code base is a big jumbled mess as its around 10 years of building on top of an out of date framework. They have very little consistency in the co...

Netbeans Forwarded over X11 Font Problem

I'm trying to forward my IDE, Netbeans, over ssh to the Xming server on my Windows Desktop. I'm able to get Netbeans to launch and run, but the fonts look terrible because they aren't being anti-aliased. I've uploaded a screenshot here. If I launch Netbeans from Gnome on the linux box itself, the fonts look fine, so it must be a probl...

transferring bytes from one ByteBuffer to another

What's the most efficient way to put as many bytes as possible from a ByteBuffer bbuf_src into another ByteBuffer bbuf_dest (as well as know how many bytes were transferred)? I'm trying bbuf_dest.put(bbuf_src) but it seems to want to throw a BufferOverflowException and I can't get the javadocs from Sun right now (network problems) when I...

Build a C# Bookshelf - what books would you include?

My primary development experience is in Java, although I have some C# experience as well. I have a library of material that I turn to often for those things that you do just infrequently enough that you don't remember the details from the last time you did something similar. The most valuable aspect of this library is that it's large e...

Is it possible to get the current line number when parsing an XML document with Xerces ?

I have a java program that parses an XML document using xerces API. My parsing class extends org.apache.xerces.parsers.XMLDocumentParser, overloading the startElement, endElement, characters methods. Since it's a complicated XML document that is written by hand (mainly some kind of configuration elements), classic validation by xsd or ...

Downloading Sun javadocs / mirror websites

The network between our company and Sun's javadocs seems to be down. Where can I get a copy of the javadocs for a given package, so that I can keep my own stash to handle network outages in the future? Are there any mirrors for the Sun javadocs? ...

Hibernate HQL Query : How to set a Collection as a named parameter of a Query?

Given the following HQL Query: FROM Foo WHERE Id = :id AND Bar IN (:barList) I set :id using the Query objects' setInteger() method. I would like to set :barList using a List of objects, but looking at the Hibernate documentation and list of methods I cannot see an obvious choice of which to use. Any ideas? ...

Are Java Applets unable to communicate with javascript within Firefox on Mac OS ?

I have a java applet running in a browser that is calling some javascript functions and expecting a result from theses functions. This is working with the following configurations : Internet Explorer FireFox / Windows Safari / Mac BUT It's not working with Firefox on MAC OS The source of the problem seems to be the win.eval calls th...

Converting an array of bytes to an array of floats

I'm currently converting a Delphi method used for random binary file access into Java. The Delphi procedure uses: TSingleArray = Array[0..MAXSIZE] of Single ... procedure GetLinkValues(const LinkVar: Integer; const TimePeriod: Integer; var Value: PSingleArray); ... BlockRead(Fout, Value^, Nlinks*SizeOf(Single)); To read an array of...

odd .bat file behavior

I have a bat file with the following contents: set logfile= D:\log.txt java com.stuff.MyClass %1 %2 %3 >> %logfile% when I run the bat file though, I get the following: C:\>set logfile= D:\log.txt C:\>java com.stuff.MyClass <val of %1> <val of %2> <val of %3> 1>>D:\log.txt The parameter is incorrect. I'm almost positive the "...

Calling mysql.exe from Java

I am calling mysql.exe from Java to load a database. Because the process just hangs, I need to create a command file and pass in the username and password. Example contents of command.bat: mysql --user="%1" --password="%2" mydatabase < myscript.sql The problem is that I cannot see the output of the mysql command to see if there were...

In java under Windows, how do I find a redirected Desktop folder?

I know using .NET languages such as C#, one can do something like Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) to find the redirected location of the Desktop. However, under Java, I cannot think of a good way to do this. What is the most appropriate way to find a redirected user Desktop directory from Java, ...

How to allow two applets to work that use different jre's

Got two applets. Applet A requires 1.6+ Applet B doesn't work in 1.6 (1.4 works) How do I get them both to work? ...