java

Changing parameters in a LinkedList

Hi there! I'm new to java so im having some "annoying" problems. I have a class Employee which contains a int idNumber and a int phonenumber. Then i have a LinkedList sorted by idNumber. I want to change the phonenumber of a certain idnumber. I've been working with Iterators but i don't know if i'm doing it right, which i doubt. public...

Load a PNG image into Java as BufferedImage through JNI C code

Hi, I have the following problem. I have C code that acquires a PNG image as basically raw data and keeps it in memory. I would like this raw data to be translated to a BufferedImage in Java, through the use of JNI. Does anyone know any way of doing this or has done this before? ...

Reading text with Java Scanner next(Pattern pattern)

I am trying to use the Scanner class to read a line using the next(Pattern pattern) method to capture the text before the colon and then after the colon so that s1 = textbeforecolon and s2 = textaftercolon. The line looks like this: something:somethingelse ...

Threading for distance vector which does not drop packets.

Hi I am doing my assignment in Network architecture 1, where I have to implement a distance vector routing at each node. At each node, I have a thread which listens for incoming DatagramPackets containing routing information from neighboring nodes only on a specific port. When a datagram arrives, the thread processes that datagram, an...

adding relative directory to java classpath and using ClassLoader().getResourceAsStream("")

Is it possible to add a relative directory (ie, foo/bar/plugh) to the java classpath and use InputStream in = getClassLoader().getResourceAsStream("xyzzy.properties"); To fetch foo/bar/plugh/xyzzy.properties? My classpath looks like this: foo.jar;foo/bar/plugh;xyz.jar And I am able to use classes and resources from both foo and x...

How to make Java console input dissapear after pressing enter

I'm using the Scanner class to take some input from the user through the console. Whenever the user inputs something in the screen and presses enter the input stays on screen for example: This is the prompt // User writes command and presses enter command output of command goes here //Use writes command3 command output of command ...

Java User Interface Framework?

I am about to build a UI in Java and I am trying to determine what I should use. I definitely don't want to use vanilla swing. The one caveat is that it has to be added inside of an existing swing application. I am looking at JavaFX and Groovy Swing Builder. For the former it looks like there is fairly poor support for embedding into sw...

Why does C# not allow const and static on the same line?

Why does C# not allow const and static on the same line? In Java, you must declare a field as 'static' and 'final' to act as a constant. Why does C# not let you declare const's as final? I make the further distinction that in Java, every interface is public and abstract, whether this is explicitly declared or not. Aren't const's ef...

Java WebStart and endorsed directories

How do I specify in java webstart .jnlp file, that some of my jars are overriding the JRE builtin implementations? Just like the endorsed lib property on a regular application. ...

how conversion of int to byte happens in java?

Hi int i =132; byte b =(byte)i; System.out.println(b); The o/p is -124 Why so ? I know this is very basic question, but still not able to map it how and what happens ? ...

Displaytag export option is not working

Hello All, I am using Displaytag framework for pagination & exporting purpose. In that i am also using Strut2Tiles Integration. Whenever i am calling any action class it will returning me a list & through Displaytag i am successfully displaying record on my page. For that my jsp page's code looks like : <s:set name="selectedPageSize...

Is there any Java API available to compare two microsoft word documents?

I am looking for a Java API which can compare two microsoft word documents. We are using Linux server so we can't install Microsoft Word in it. EDIT :- We want to compare two document and what ever things are not common that we have to highlight with some color or any other way ... So I thing we have to merge both document and highligh...

GZIPInputStream decompression did not work fine for the compressed data with length more than 532 bytes

I have created compression and decompression using gZipInputStream in java It works fine for small amount of data but if the data length after compression becomes greater thatn 532 then my decompression does not work fine. Thanks Bapi ...

Algorithm for analyzing text of words

I want an algorithm which would create all possible phrases in a block of text. For example, in the text: "My username is click upvote. I have 4k rep on stackoverflow" It would create the following combinations: "My username" "My Username is" "username is click" "is click" "is click upvote" "click upvote" "i have" "i have 4k" "have 4...

JList select items with all mouse buttons

hello, how can i make a swing JList to have its items selected with any mousebutton not just the left one? thanks! ...

Sequence comparison in java.

I'm looking for a standard algorithm/code (Java) which compares two integer lists (old and new) and gives a third result list which provides actions to convert the 'old' list into the 'new' list. For example: old-> 1, 2, 3, 4 new-> 9, 2, 3, 6, 4 so the result should be something like: 1-, 9+, 2, 3, 4-, 6+, 4+ Here, the suffix: ...

Should SDO (Service Data Object) be adopted in new project ?

I've been programming in Delphi with Midas/DataSnap for quite long time and quite happy with it. Moving to .NET I'm more than happy with the ADO.NET DataSet. For CRUD application, I'm highly uncomfortable with any kind of ORM. Generic data-structure with automatic diff/delta handling get my job done better for me, an average database a...

java xml validation problem with schema

I can validate an xml with schema in java using DOM parser. But here both the schema and xml file have namespace. Now I want to validate an xml without namespace with schema. How to achieve this Thanks Bapi ...

Read memory of Java applet running inside browser

Hi, I use C# to program and use ReadProcessMemory to read the memory of other processes running on the system. However, I'm unsure how to read the memory of a java applet that is running inside a browser? Has anyone tackled this before? Thanks. ...

Asynchronous channel close in Java NIO

Suppose I have simple nio based java server. For example (simplified code): while (!self.isInterrupted()) { if (selector.select() <= 0) { continue; } Iterator<SelectionKey> iterator = selector.selectedKeys().iterator(); while (iterator.hasNext()) { SelectionKey key = iterator.next(); iterator.remove(); Selectabl...