java

Nested Generics with Wildcards

Why does this work: List<?> list = new LinkedList<Integer>(); while this gives a type dismatch error: List<List<?>> list = new LinkedList<List<Integer>>(); Why is this? Ist there a way around this, without using raw types? ...

java generics/inheritance in nested hashmap

hi all, if i have two hashmaps, of types HashMap<Integer, HashMap<Integer, Police>> time_id_police; HashMap<Integer, HashMap<Integer, Ambulance>> time_id_ambulance; where Police and Ambulance both extend Rescue, how can i have a method like HashMap<Integer, HashMap<Integer, Rescue>> getRescue(){ if (a) return time_id_police; ...

Java runtime.exe() Error launching browser : error accessing current directory

I have been trying to launch browser from a java app on Linux. When this app is run for the first time browser don't get opened. The error log shows : shell-init: cannot get current directory getcwd : no such file or directory. After this if u restart everything falls into place and browser opens fine. I have tried many things like cha...

Spring JDBC support and large dataset

When using one of the various JDBC template methods I am confused on how to iterate/scroll over large result sets (which won't fit into memory). Even without a direct exposure of an Iterable interface I would at least expect instances of RowCallbackHandler to get called while the query is executing not after it's finished (or the heap ov...

Does a Java Scanner implicitly create a buffer even if you do not pass it one?

If I have the following example file where each number is represents a byte (123 has bytes 1, 2, and 3): 123456789 Let's say I create a FileInputStream. This reads in the binary byte by byte. So .read() returns 1, then 2, etc. Now let's say I create a buffer. The initial chunk it reads in (if I understand buffers correctly) is 1-5. Th...

Java - is it possible to read a file line by line, stop, and then immediately start reading bytes where I stopped?

I'm having an issue trying to parse the ascii part of a file, and once I hit the end tag, IMMEDIATELY start reading in the bytes from that point on. Everything I know in Java to read off a line or a whole word creates a buffer, which ruins any chance of getting the bytes immediately following my stop point. Is the only way to do this rea...

When is "obj instanceof Object" false in Java?

Consider Object obj = ....; System.out.println(obj instanceof Object); What should obj be so that the answer is false (Any other option other than null) ...

file path in WebApplication using GlassFish

I'm using a class to get a property file under the source folder. But it doesn't work! After checking, I found that the default path by using the File f = new File("/src/ss.properties"); is not the web application path but the glassfish config path! What can I do if I want to fetch the property file stored in the "classes" path? Usually ...

Using log4j in oc4j 10.1.3

I have a web application running on OC4J 10.1.3. I am trying to do some logging using log4j. The messages show up in my IDE console as expected, but nothing is going into the application.log in OC4J. Anybody know what I need to do to get this working? Here's my log4j.properties: log4j.rootCategory=DEBUG, CON1 # CON1 is set to be Co...

Differences between JPA and JPA2

Does anyone have a list of the changes between JPA 1 and JPA 2? I have read about the Criteria queries and other changes, but I would like a "what's new" kind of reference. Thanks ...

How do I make a thread wait for JFrame to close in Java?

When the program starts, a new JFrame is created. Once the user clicks the start button a thread is created and started. Part of this threads execution is to validate the data on the form and then execute with that data. Once the data has been validated the thread calls dispose() on the original frame and then creates a new JFrame that a...

Do Tomcat JDBC Connection pools get shared between instances?

We have a web application right now that we deploy a copy for each client. Our current deployment strategy is to create a uniquely named jdbc connection pool for each instance. so say jdbc/client. They are specified like this... < Context path="/" reloadable="true" docBase="\home\client\ROOT" debug="5" > ...

Java v/s PHP, how do this technology stack up for Web Application Development ?

Hi, I am new to Web Programming and I hear that there are many biggies like Java, .Net and PHP for Web Application Development. I would certainly appreciate if I can get some insights on how this technology stack up in comparison and in what scenarios one would prefer one technology over the other. Thanks for all guidance in advanc...

Hibernate configuration on runtime

Hi again. I have hibernate.cfg.xml file. <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url"></property> <property name="connection.username"></property> <property name="connection.password"></property...

Get active processes through Java on Windows 2000 Pro

I want to get the name of all active process on a Win2000 machine. I know that "tlist -s" is the command, but to use this, the "tlist.exe" has to be extracted from the Win2000 CD-ROM. I also know "tasklist" only works on XP or greater. I am running my tests on VM Ware, and do not have a CD-ROM. Is there another way to programmatically g...

Update of of Composite Entity fails

I have Person entity which has composition with Location Entity @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE }) @Cascade( {org.hibernate.annotations.CascadeType.SAVE_UPDATE }) public Location getLocation() { return location; } And Location Entity has Name as Id @Id public String getName()...

java GUI freezing because of insertString method?

Hi all, Have you ever heard about a GUI freezing because of repeated calls to the method javax.swing.Document.insertString ?? There is my code: private int insertNotation(GameNode startNode, StyledDocument doc, int pos) { String s = ""; int startPos = pos; boolean isContinuous = false; Style boldStyle, regularStyle, ...

How to create a Java timer that repeats at different times

I have some stock market data. I want to simulate the stock market by having prices sent at intervals that can be determined from the times at which trades occur. What would the best way be to do this. So far I have a class with static variables and methods in which I am storing the hour, min, millseconds for the last trade time. I th...

Spring: Is there a simple non-web tutorial?

I'm attempting to create a Spring application (NOT web application) to perform some simple tasks. Eventually they will hook up with some other Spring apps around the network, but for now I'm keeping it simple. I have a CheckForNewItems class (extending Timer) which is configured to run every 10 seconds. I can confirm it runs by calling ...

How would one implement an FPS camera?

So I'm currently working on some FPS game programming in OpenGL (JOGL, more specifically) just for fun and I wanted to know what would be the recommended way to create an FPS-like camera? At the moment I basically have a vector for the direction the player is facing, which will be added to the current player position upon pressing the "...