java

[Java] How to open file without extension

I would like to try open file without extension. When I try to open file without extension, then system show me "Open with" form. But when I am trying to open that file in side my application using method: private static void openFile(String fileName) throws IOException { if(Desktop.isDesktopSupported()) { Desktop desktop...

HashCodeBuilder in C++

In java, if I want generate a id for a given object, the easyest way I know is to use apache commons: public class Person { String name; int age; boolean smoker; ... public int hashCode() { // you pick a hard-coded, randomly chosen, non-zero, odd number // ideally different for each class return new HashCo...

Transaction mode for file operations in Java

Hi there, Perhaps what I'm trying to explain here doesn't make any sense, so I'd like to apologize in advance. Anyway, I will try. I'm trying to read from a file, perform some database operations and move the content to another file. I was wondering if it is possible to perform all this operations in an atomic way in Java, so if anythi...

Java Datastructures

Greetings, I've been working out of an embedded version of Java where the height of complex structures included in the API was a vector or queue. This usually meant writing structures from scratch when needed. I am now coming back to the land of the living, I will have full access to a real version of java with all the bells and whis...

Running a JavaScript command from MATLAB to fetch a PDF file

I'm currently writing some MATLAB code to interact with my company's internal reports database. So far I can access the HTML abstract page using code which looks like this: import com.mathworks.mde.desk.*; wb=com.mathworks.mde.webbrowser.WebBrowser.createBrowser; wb.setCurrentLocation(ReportURL(8:end)); pause(1); s={}; while isempty(s)...

Japanese characters in java webapp and oracle

Hi. I want to write a simple java web app that takes japanese characters and stores in db.(Oracle). My server is tomcat. What are the things I need to ensure, rather what all places my encoding should be set correctly? I have UTF-8 in my IDE, and probably database config is also set to UTF-8. Would that be enough? Does my server con...

java.util.Date - Deleting three months from a date?

I have a date of type java.util.Date I want to subtract three months from it. Not finding a lot of joy in the API. ...

Finding the position of search hits from Lucene

With Lucene, what would be the recommended approach for locating matches in search results? More specifically, suppose index documents have a field "fullText" which stores the plain-text content of some document. Furthermore, assume that for one of these documents the content is "The quick brown fox jumps over the lazy dog". Next a sear...

Is it possible, In JSP, to print the value of a variable whose name is in another variable ?

The problem i am having is like this there is variable <core:set var="type">*one of: load,migrate, or ...* </core:set> and the value of load, migrate, is a map. Now, i want to print the value of these based on the type? Is it possible at all? ...

Tool for creating a Java daemon service on Linux

What is the best way to create a java application that can be run using ‘service’ on Linux? I was going to use the JSW available here, but cannot use the licence on that (licence is either GPL or it costs money as far as I can tell). I’d need an apache style licence. I’m using maven to build, so it would be great if it was possible to c...

Keyword (OR, AND) search in Lucene

Hi, I am using Lucene in my portal (J2EE based) for indexing and search services. The problem is about the keywords of Lucene. When you use one of them in the search query, you'll get an error. For example: searchTerms = "ik OR jij" This works fine, because it will search for "ik" or "jij" searchTerms = "ik AND jij" This works fi...

how to tell if VM is running in server or client mode?

The Java hotspot vpm can be run with -client or -server argument. If neither is specified then it chooses one according to some rules. Is it possible to tell whether a running VM is running in client or server mode when the mode is not specified on command line? I need this on a Windows box outside the running process. I realize this i...

property-placeholder location from another property

Hi I need to load some properties into a Spring context from a location that I don't know until the program runs. So I thought that if I had a PropertyPlaceholderConfigurer with no locations it would read in my.location from the system properties and then I could use that location in a context:property-placeholder Like this <bean cl...

Netbeans with Oracle connection java.lang.ClassNotFoundException

I use NetBeans 6.5 . When I try to run the following code : package com.afrikbrain.numeroteur16; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author */ public class NumeroteurTest { public NumeroteurTest() { } ...

Whats the difference between "${foo.bar}" and "#{foo.bar}" ?

I can use objects from my Java Beans within .jsp files by using the Expression Language (EL). Therefore I can get my value by typing ${foo.bar}. But I can also use #{foo.bar}. Can anybody explain the difference or provide a link with meaningful information? ...

Change the "name" value of a signed Java applet

Hi, I've (self-)signed a java applet, so when a user views this applet in a browser, the browser will show a "digital signature cannot be verified" confirmation dialog. That's all ok, but: The value of the "Name:" property (seen above the "Publisher:" property) of this confirmation dialog is set to something I don't remember setting w...

Problem while running python script in java code

When i run a python script from the below java code, where an input file is given as an argument to the python script as well as an "-v" option, i get a IOException String pythonScriptPath="\"C:\\Program Files\\bin\\CsvFile.py\""; String Filepath="C:\\Documents and Settings\\user\\Desktop\\arbit.csv"; String[] cmd = new String[4]; cmd[0...

Axis2 Migration

Hi, We had an application using axis2 1.0. We recently migrated to axis2 1.4. After migration we are facing the following error at runtime: public static org.apache.axis2.context.ConfigurationContext org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromURIs(java.net.URL,java.net.URL) throws org.apache.axi...

ORA-0 [BEA][Oracle JDBC Driver] Unhandled sql type

I have a very simple sql query and when i try to execute, i get following error java.sql.SQLException: [BEA][Oracle JDBCDriver]Unhandled sql type at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source) at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source) at ... I have configured weblogic datats...

JScrollPane with scroll bar to left

I need to place a scroll bar to the left of the contents in my JScrollPane. Can it be done without a separate JScrollBar component? Perhaps simply by setting some alignment? ...