java

How do I get just the jar URL from a jar: URL containing a ! and a specific file in the jar?

Hi, I get a jar file url at runtime as: jar:file:/C:/proj/parser/jar/parser.jar!/test.xml How can this be converted to a valid path as: C:/proj/parser/jar/parser.jar. I have already tried using File(URI), getPath(), getFile() in vain... ...

Typeahead / Incremental Search in java

Hello, we've got a list of search-result mappings, e.g. a simple url mapping might look like "stackoverflow" -> "www.stackoverflow.com" "joel" -> "www.joelonsoftware.com" so searching for the exact phrases is working fine. Now we're looking for an incremental search / typeahead, e.g. "stackover" would also return "www.stackoverflow....

Java: Is there a tool available that can allow me input, store, and evaluate math formulas?

Even something very rudimentary is fine. Like entering and evaluating something like x+1, where x is a variable I get to specify. I was thinking of writing my own using Strings for each formula, regex for parsing them, etc., but let's assume my goal is to be as lazy as I can possibly get away with, and that if there's another option (e...

What makes the Java compiler so fast?

I was wondering about what makes the primary Java compiler (javac by sun) so fast at compilation? ..as well as the C# .NET compiler from Microsoft. I am comparing them with C++ compilers (such as G++), so maybe my question should have been, what makes C++ compilers so slow :) ...

How do I read a resource file from a Java jar file?

I'm trying to access an XML file within a jar file, from a separate jar that's running as a desktop application. I can get the URL to the file I need, but when I pass that to a FileReader (as a String) I get a FileNotFoundException saying "The file name, directory name, or volume label syntax is incorrect." As a point of reference, I h...

Java cannot find symbol compile error

Hi, new to Java. I want to use the org.apache.commons.lang.WordUtils package. Tried importing it. Tried downloading it and adding it to my build path. When I use intellisense for the word WordUtils Eclipse auto puts the import statement at the top of the file. I get the following error when compiling: ConvertToUrl.java:3: package org....

Creating nunit tests without exporting them with the api

I'm new to unit testing using nunit (and Java development in general). When creating unit tests for private methods on classes, it looks as though the test file must be in the same package as the class being tested. What is the typical way of avoiding exporting the APIs of the unit tests? Can I make the classes/test methods package-pr...

Switching from Java to C++ - what's the easy way?

I have ~2 years of experience in Java programming, and it is basically the first programming language I have made serious and intensive use of. Currently, I need start switching to C++ for some assignments I have. Up until now I have been very comfortable with Java, and it's concepts made lots of sense to me. Just off the top of my head...

Value object with OID

Can you describe the pros and cons of including an OID (typically a database row identifier) in a POJO representing an entity in your model? In fact I'm not talking about issues related to equals/hashcode and so on, I should have described better my problem (my bad :) )... We've got some of those entity classes which represent business...

Can you organize imports for an entire project in eclipse with a keystroke?

Wouldn't it be nice to just do a keystroke and have eclipse organize all imports in all java classes instead of just the one you are looking at? Is this possible? Is there a keystroke for it? ...

What is the use of package level protection in java ?

I know how package level protection in java works. I read a lot of code (including lots of open source stuff) and no-one seem to be using it. The whole protection level seems slightly faulty to me (I'd have c#'s internal any day of the week). Are there any legit real-world use-cases that are in common use ? Edit: A little too late aft...

Determining the path to Outlook.exe from java?

I want to invoke outlook from the command line (for various reasons) and wanted to know how I go about discovering the Path to the Outlook.exe file. I'm pretty sure it's stored in the registry, but was wondering how to go about reading that from Java. thanks ...

Does it make sense to use a framework for a simple java web app?

I've done lots of java web development using jsps and servlets, and I have found this approach to be straightforward and flexible. Some of the groundwork involved though - such as managing database connections - is rather tedious, and it takes a fair amount of work just to get a new web app off the ground. I'm therefore considering us...

Best way to alter constants in Java build process

I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons, the code has different "look and feel" options based on where the application will be deployed (essentially a matter of branding). There are several constants that control this branding process, which have different functions and should not be...

Disable tap clicks

When on a Tablet PC, touching the screen with your pen is interpreted as a click. The sensitivity is adjusted so that even if your pen slips a little bit, it is still interpreted as a click; you have to move a certain distance before it becomes a drag-n-drop event. In a notebook style application, however, you never want to "click" insi...

How do I format and read XML processing instructions using Java StAX?

First, how do I format the XML processing instruction, is it: <?processingInstructionName attribute="value" attribute2="value2"?> Using StAX, I then want to read it by handling the XMLStreamConstants.PROCESSING_INSTRUCTION (javadoc) event, but it only provides two methods to then retrieve information about the processing instruction f...

Spring SP Class generation with or without Eclipse

With Hibernate+Eclipse you can generate POJO classes that represent the tables. You can then wire it all together pretty easily with Spring. However, if you have to interact with stored procedures you have to wrap each one in it's own class(es) -- although this is definitely preferred to standard JDBC it is still a bit cumbersome at time...

Java calendar time, minute is wrong

Anyone know why the MINUTE method in java.util.Caldendar returns an incorrect minute? import java.util.Calendar; public class Clock { // Instance fields private Calendar time; /** * Constructor. Starts the clock at the current operating system time */ public Clock() { System.out.println(this.time.H...

Programmatically transcode MPEG-2 videos

I need to be able to programmatically transcode mpeg-2 files to .mp4, .mp3, .wmv, .rm (optional), and .flv (optional), and hopefully generate a thumbnail as well. I found the Java Media Framework, but it frankly looks pretty crappy. This will be running a Linux server, so I could shell out to ffmpeg using Commons Exec - does ffmpeg do ev...

Java: how to check if character belongs to a specific unicode block?

I need to identify what character set my input belongs to. The goal is to distinguish between Arabic and English words in a mixed input (the input is unicode and is extracted from XML text nodes). I have noticed class Character.UnicodeBlock : is it related to my problem? How can I get it to work? Edit: The Character.UnicodeBlock ...