java

I need a fast key substitution algorithm for java

Given a string with replacement keys in it, how can I most efficiently replace these keys with runtime values, using Java? I need to do this often, fast, and on reasonably long strings (say, on average, 1-2kb). The form of the keys is my choice, since I'm providing the templates here too. Here's an example (please don't get hung up on...

How To Parse a URL in J2ME

I'm trying to extract the query's name-value pairs from a URL using J2ME, but it doesn't make it easy. J2ME doesn't have the java.net.URL class nor does String have a split method. Is there a way to extract name-value pairs from a URL using J2ME? Any open source implementations would be welcome too. ...

GlassFish v3 Prelude - admin questions

I've been mucking around with GlassFish v3 prelude this evening. A couple of things I'm not sure about is how the security works. It installed like a dream, so the first thing I did was remove the anonymous account and setup an "admin" account with "mysecretpassword" and specified the asadmin group for this user in the admin realm. At ...

Java and other clients for WCF RESTful Services

I am wanting to expose some data service endpoints for internal application use and am debating on WCF REST as a possible solution. What are my options for other languages/platforms as clients? Keeping in mind that I need to service Java, Python and .Net clients. Essentially, I want to be able to demonstrate a single point of organ...

As a Java developer, C or C++?

I've been writing Java professionally for the last 5 years. Recently, I've had to dig into JNI a bit to call some Windows specific functions. This experience has highlighted my poor command of the C (or C++ for that matter) language. My only introduction to C was a brief "dummies" book that I read in high school 11 years ago. I know ...

Java Methods

Hello programmers! I know this site is for advanced programmers only but I hope that it is also for newbies :) It really hard for me how to use methods in creating a java program, can you please help me? I hope that your answers and explaination will greatly help me. ...

Using java (desktop) codebase in a webapp

I have a rather large (80k loc) java desktop app that talks to a database. We're now looking at exposing some parts of the database via a web application, using the existing codebase and preferably not having to modify it. I have good separation between the data access, business logic and presentation layers, but we haven't used enterpr...

String conversions

I have a method which takes String argument.In some cases i want to pass int value to that method.For invoking that method i want to convert int into String.For that i am doing the following aMethod(""+100); One more option is aMethod(String.valueOf(100)); Both are correct.I don't know which is appropriate?Which gives bett...

Creating a new file using an existing file within a jar

Let's say I have a file called test.txt within the package "com.test.io" within my jar. How would I go about writing a class which retrieves this text file and then copies the contents to a new file on the file system? ...

Does a finally block always run?

Is there any condition where finally might not run in java? Thanks. ...

How to build a Google-chrome tabs and menubar interface in Java Swing?

Does someone know an open source project or code snippets, which demonstrate how to create a google-chrome like interface with similar tabs and toolbar in Swing? I know, that I can use JTabbedPane, but I'm thinking of an interface which looks and feels very similar to the google chrome "tabbed browsing". ...

Java Threads: Specifying what should be executed in the run function

I have a DBAdmin class that connects to the database, and then some other classes such as Article, Category and so on, that perform certain queries to a database. I am using these classes in a Swing application to build a sort of small Intranet CMS application. Now, the Category class has a bunch of static methods such as addCategory, ...

Strange classes passed from matlab to java

I have some matlab code and some java code that need to talk. I was getting a NoSuchMethodError When I pass a matlab double array to a java method that accepts double[] argument. So i write a simple "hello world" to get the class of an object passed to the method public void printArray(Object array) { System.out.println(array....

Transaction options over Web Service calls

Does anyone have any insight into transaction options available over web-service calls? 1.) There are two applications that we have that need transactional communication between them. 2.) App1 calls a web service on app 2 and then makes some changes to its own db. the call on app2 and the changes to it's own db need to be co-ordinated. H...

Is it possible to control CPU usage from a Java application?

I'm developing a Java application that streams music via HTTP, and one problem I've come up against is that while the app is reading the audio file from disk and sending it to the client it usually maxes out the CPU at 90-100% (which can cause users problems running other apps). Is it possible to control the thread doing this work to us...

External program from our Java program

How can I write a program in Java that will execute another program? Also, the input of that program should be given from our program and the output of that program should be written into a file. This is my small set of code to get its output: Process p = Runtime.getRuntime().exec("C:\\j2sdk1.4.0\bin\\helloworld.java"); BufferedReader ...

How to implement OpenID in Java

How would I go about supporting OpenID authentication in an Java web application? ...

Best tool to check and ensure PDF/A compatibility under Linux

I am working on an online portal, where researchers can upload their research papers. One requirement is, that all PDFs are stored in PDF/A-format. As I can't rely on the users to generate PDF/A conforming documents, I need a tool to check and convert standard PDFs into PDF/A format. What is the best tool you know of? Price Quality Sp...

How to capture selected screen of other application using java?

We are trying to develop a screen capture utility. How do we capture selected screen of another application using Java? And how do we add a callout to the captured screen? ...

running rmi server, classnotfound

Hi I'm trying to run a java application that binds a class to the naming server, but i constantly get a ClassNotFoundException First I start the registry: rmiregistry then from eclipse I try to execute the server but get this error java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: ...