java

Why the name main for function main()

Why the function name main() is retained in many languages like C, C++, Java? Why not any other names for that function? Is there any common structure for all these 3 main() (in C, C++, Java) ...

Java, how to add a "comparator" class to increase code reusability

Preface: I'm posting this on behalf of a friend (who's apparently to shy to post it himself), I browsed through the related questions and I didn't seem to find any duplicate.. But do note that I don't know Java at all so I apologize in advance if this is a duplicate! This is part of the code: public class ElencoEsami implements Compara...

calling shell script from java application

I have a java application from which i am calling a shell script. Can any one tell where to keep the script file in my application and what is the path to access the file in whole application. i m keeping my script in the java package but when i m trying to access using path like com.abc.script.sh by running my java application through ...

NIO file channel transfer problem on iSeries

Hi all, I'm having a problem with some Java NIO code running on an iSeries box (JDK 1.5). Basically the code is splitting a file up into chunks part of a file to another smaller files. The same code has been operating on other iSeries boxes for some time with no problems. Here's the code snippet: //copy original data file content to te...

How can I resize the background of a JLabel or apply top and bottom borders only?

I've got sort of weird issue that I can't seem to figure out. I have something that looks like this: As you can see, "Blambo" is a JLabel with an opaque, red background. The label sits on top of a little grey bar that has a single pixel blackish border all the way around it. I'd like my red warning to match the bar it's sitting on ...

Frequently Used metadata Hashmap

Are there any implementations of a static size hashtable that limits the entries to either the most recently or most frequently used metadata? I would prefer not to keep track of this information myself. I know most caching components keep track of this, but I would rather not introduce quite a lot of new dependencies. ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for logging in and out, so there's no trivial way to employ Google Accounts features in a thick client. Can you give some advices/hints/ideas...

Problem with AnnotationSessionFactoryBean

I use the following configuration for initiating my SessionFactory: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/...

Conditionally ignoring tests in JUnit 4

OK, so the @Ignore annotation is good for marking that a test case shouldn't be run. However, sometimes I want to ignore a test based on runtime information. An example might be if I have a concurrency test that needs to be run on a machine with a certain number of cores. If this test were run on a uniprocessor machine, I don't think ...

Buffered Images in java

static BufferedImage img1[]; for(int i=0;i<60;i++) { img1[i] = new BufferedImage((int) (width), (int) (height), BufferedImage.TYPE_INT_RGB); } It shows an error on the line above this code : Syntax error on token ";", { expected after this token and below this code as: Multiple markers at this line - Method breakpoint:V...

Java/Scala BigInteger Pasting

I have a problem with the Java BigInteger class: I can't paste a large value into BigInteger. For example, let's say I want to assign a BigInteger to this number: 26525285981219105863630848482795 I cannot assign it directly, because the compiler thinks it's an integer: val bi = 26525285981219105863630848482795 //compile error But I...

Java - Instantiating objects of type X when all you have is the reference type

I had a quick look at the "Related Questions" suggested but I couldn't find one directly related to what I'm asking. Even if there was one, I'd still appreciate your opinion on the best way to do this. First some context. I'm working on extending a Java Application and I have the following Interface and Class: public interface Mapper {...

Supporting Different JPA GenerationTypes for Test/Production

I want to use GenerationType.IDENTITY for primary keys in my production MySQL system. But for local development and testing, I'd like to use HSQLDB. The problem is that HSQLDB doesn't support GenerationType.IDENTITY (at least with Eclipselink). I tried setting GenerationType.AUTO, which defaults to TABLE for HSQLDB, but unfortunately it ...

Hibernate in Servlet causesNoClassDefFoundError: org/slf4j/LoggerFactory

I have a Java (6) application which uses Hibernate (V3.3.2) to read data from HSQLDB, which i build and debug/run with Eclipse (V3.5.1), and it works fine. I then created a GWT (V1.7) Servlet web app, copied my hibernate classes into it, and added the same User Libraries dependencies. However when i run the servlet and try to access a U...

Default arguments in JAR-manifest

Is there a way to create a JAR-file that contains some arguments that are passed to the main class? (It does not matter whether it prepends or appends the arguments to potential command line arguments.) I know I could simply write a bootstrapping class and specify this as main class (calling the real main class with the arguments), but ...

Birt report file path

I'm trying to setup Birt running under Jetty. I can get the "congratulations" report to run: http://10.10.11.1:8080/reports/frameset?%5F%5Freport=test.rptdesign&amp;sample=my+parameter However, I am not able to get any other reports to run. I have the BIRT viewer running from the "reports" context. Trying to run one of the sample repor...

JOGL and Snow leopard

Hi everyone, I'm having some major issues with getting JOGL to work on snow leopard. I've installed all the necessary JOGL jars in /system/library/java/extensions I can get sample code to compile but when I attempt to run it it throws the error following error on trying to actually display the window. Exception in thread "main" jav...

Add JScrollPane to a panel that shows an image

i have this little program for showing images on apanel.. but i'm not able to add a scroll to it.. and this is my code the class that extends jpanel to show the image: public class ShowPanel extends JPanel{ public ShowPanel(BufferedImage image, int height, int width) { this.image = image; this.height = height; this.width = width...

program with java

I'm writing a program with java that uses bitwise operations to: (1) generate and display all power-of-two numbers in the range +128 to -128, and (2) display an arbitray user-input integer. Have to provide two methods- main and display.main method should declare int number = 128, include a while loop that loops while number is >= -128, c...

Is there a way to put Java objects in a POST request from a JSP?

I have a JSP page that renders, and calls a Web service to load some initial data. The user fills out some form information, and then submits it to the server, which could possibly return the same JSP page for further processing (and another submit). The initial data never changes, but it is an object representation, so I'm trying to fig...