java

Running a WPF User control or Managed Directx control on JFrame

If I have developed a user control as mentioned in the tile and I use this http://www.ikvm.net/ to convert my .dll to a Jar file, Can I then embed that control on my JFrame? If so can you give an example please. ...

Quartz API error.

When I compile and run my application on my local machine with specs Windows XP sp2, JDK 5u11, I get no error. But when I try to run this application (compiled on Windows XP) on a Linux Debian distro, JDK 5 I get the following error: Unable to instantiate class load helper class: null What can I do to get rid of this exception message...

DataOutputStream not flushing

I have a Java Client which sends UTF-8 strings to a C# TCP-Server, I'm using a DataOutputStream to send the strings. The code looks like this: public void sendUTF8String(String ar) { if (socket.isConnected()) { try { dataOutputStream.write(ar.getBytes(Charset.forName("UTF-8"))); dataOutputStream.flush(); } catch (IOException ...

Why java has fixed data type size unlike C

In C as we know the size of data types (ex. int) can vary depending on compiler / hardware. But why the size of data types is constant in java language? why don't we have the flexibility for different data type size in java depending on compiler? ...

Use default KeyMap of native OS

In Java, by using non-default system look and feel we will have different keymap. For example I'm using Mac OS X and use Substance look and feel (non-default system look and feel). The effect is I'm loosing my "meta" key for select all on text component In mac os x should be "meta + a", but using Substance we have to use "ctrl + a" (and...

Determine the most common occurance in an array

Assume I have an array of doubles that looks like the following: Array[10] = {10, 10, 10, 3, 10, 10, 6, 10, 10, 9, 10} I need a function that can determine what the MAJORTY vote is in the array, in this case "10" because it is the number that appears the most often... And of course there is the situation when no majority exists (where...

Java RESTful class/library support without annotations?

Hi there, I am looking for a simple Java library (having a friendly license; Apache2, MIT, BSD) that I could use for parsing http RESTful requests. I will be taking care of representing the resources but I don't want to reinvent the mapping and the URI transformations, if possible?! I need a simple support for parsing routes, such as: ...

Maven stuck on old version of system dependency

My Maven project has a dependency on a non-Maven library, which is coded as a system dependency: <dependency> <groupId>com.example</groupId> <artifactId>foo</artifactId> <version>${foo.version}</version> <scope>system</scope> <systemPath>${foo.jar}</systemPath> </dependency> where the location of the library can be controlle...

How to inspect the stack using an ASM visitor?

I am attempting to use the Java byte code engineering library ASM to perform static analysis. I have the situation where I would like to inspect the variables being assigned to a field. I have MethodVisitor which implements the visitFieldInsn() method. I am specifically looking for the putfield command. That is no problem. The problem i...

Overloaded package-private method causes compilation failure - Is this a JLS oddity or javac bug?

I've come across an oddity of the JLS, or a JavaC bug (not sure which). Please read the following and provide an explanation, citing JLS passage or Sun Bug ID, as appropriate. Suppose I have a contrived project with code in three "modules" - API - defines the framework API - think Servlet API Impl - defines the API implementation - t...

capture image from web cam

Hello friend, I am using jmf to capture image from web cam. I have attached webcam and it is working with fine. I am using following code to capture image from webcam: -- import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGEncodeParam; import com.sun.image.codec.jpeg.JPEGImageEncoder; import j...

Java Swing JEditorPane: manipulating styled documents

I have model that is a queue of Strings associated with enum types. I'm trying to display that model in a JEditorPane, with each element in the queue as a separate HTML paragraph that has attributes based based on the associated enum type. However, my updating methods are not doing what I want. I tried writing the HTML strings directl...

Should a function's comment include descriptions of work done by functions it calls?

Let's say I have a function called DisplayWhiskers() which puts some slashes and backslashes on the screen to represent an animal's whiskers like this: /// \\\. I might write a comment for this function along the lines of // Represents an animal's whiskers by displaying three // slashes followed by a space and three backslashes But ...

Sorting a very large text file in Java

Hi, I have a large text file I need to sort in Java. The format is: word [tab] frequency [new line] The algorithm for sorting is: Read some of the file, filtering for purlely alphabetic words. Once you have X number of alphabetic words, call Collections.sort and write the result to a file. Repeat until you have finished reading the f...

Java File Transfer getting stuck halfway

I am trying to send a file (an image sent as a byte array) with the client and then the server should receive said byte array to make further use of it. However when I click on the "send" to send the image the file transfer starts (as I get a sentImage.jpg in my Desktop) but it gets stuck for some reason I can't figure out and the image ...

Java Stanford NLP: Spell checking

I'm trying to check spelling accuracy of text samples using the Stanford NLP. It's just a metric of the text, not a filter or anything, so if it's off by a bit it's fine, as long as the error is uniform. My first idea was to check if the word is known by the lexicon: private static LexicalizedParser lp = new LexicalizedParser("englishP...

parsing CSS with Java

I need to parse CSS files in Java, and have tried using the Batik and CSSParser libs with success. The issue I am having is that when I run into IE hacks, I loose the formatting; it appears to me that the DOM used by org.w3c.css.sac won't accommodate the IE Hacks. e.g.- /* The '\' isn't retained */ someselector { padding:...

Event Dispatch Thread meets the Java Memory Model

This is related to an earlier question I asked, where the answer was: If a field is accessed by multiple threads, it should be volatile or final, or accessed only with synchronized blocks. Otherwise, assigned values may not be visible to other threads. In addition anything that manipulates pixels on screen should be run f...

Syntax Highlighter for Java

Hello friends, As you know there is a Syntax highlighter for PHP called GeSHi which supports a great number of Programming Languages or Code formats. However, I couldn't find such a library for Java which supports programming languages that I need (ADA, ASP, BNF, Bash, Brainfuck, C, C++, C#, CSS, Cobol, ColdFusion, D, Fortran, Haskell,...

How can I retrieve a feed in JSON from a Java Servlet?

I want to make an Http request and store the result in a JSONObject. I haven't worked much with servlets, so I am unsure as to whether I am 1) Making the request properly, and 2) supposed to create the JSONObject. I have imported the JSONObject and JSONArray classes, but I don't know where I ought to use them. Here's what I have: ...