java

Get Previous Day

Possible Duplicate: How to determine the date one day prior to a given date in Java? If I have a Java.Util.Date object, what is the best way to get an object representing the 24 hours in the past of it? ...

How to send interrupt key sequence to a Java Process?

I've got a handle to a Java Process instance and its associated streams. It's a console program. I'd like to simulate a break sequence. On Windows this is Ctrl-C. Is this possible without natives? The reason for doing this: the console program is a command-line console itself, controlling a virtual machine for another language. The user...

How to enable GUI behaviors for sorting a JTable when SQL does the sorting?

How do I enable JTable icons and behaviors for sorting table rows by a column, without letting it use a comparison predicate to do the sorting? That is to say, how do I tell the table headers to show the arrow for ascending/descending sort order in the column being used, and get it to call appropriate methods when sort order/column chan...

What are the pros and cons of checked exception?

Do you prefer checked exception handling like in Java or unchecked exception handling like in C# and why? ...

Best Spring/Hibernate configuration for never changing tables

I'm currently using Spring+Hibernate+MySQL for a project I'm working on. I realized that a have quite a few tables which never change. They are static, no insert or updates can ever occur on these tables, and so can be considered immutable. All accesses to these tables are via lazy loading (can be made eager) of entity collections and...

Can findComponentAt() work before a JComponent is painted?

I am working on a GUI where the JComponents are "stamped" on the screen. In other words, the actual components aren't displayed, but images of the components. This is a graph, where the nodes of the graph are custom Swing components - or rather stamped images of Swing components. Now I want to display tooltips for specific components ...

Adding additional JPanels to a JPanel

Rather basic question here guys. Basically I have code like this: public SuperPanel() { setLayout(new BorderLayout()); add(panel1(), BorderLayout.NORTH); add(panel2(), BorderLayout.CENTER); add(panel3(), BorderLayout.SOUTH); } And that all works well and good. The problem is that I have another part I wish to add to t...

EJB - confused about Home/Remote -- LocalHome/Local interfaces

Revising some past exam papers for an exam mainly focus on component-oriented design and J2EE, I have come across the following question: A preliminary investigation of scenario 3: “Exchange Request” suggests that two EJBs will provide a suitable solution: a session bean called EnterExchangeRequest to control the processing and an entit...

Can Hibernate work with MySQL's "ON DUPLICATE KEY UPDATE" syntax?

MySQL supports an "INSERT ... ON DUPLICATE KEY UPDATE ..." syntax that allows you to "blindly" insert into the database, and fall back to updating the existing record if one exists. This is helpful when you want quick transaction isolation and the values you want to update to depend on values already in the database. As a contrived exa...

What is "static"?

I'm beginning to program in Java. public static void main(String[]args) A book said that I should use static in this case, but doesn't clearly say why I should or what it means. Could you clarify this? ...

Is there an API to draw a B-TREE?

Hi there, That's a simple question: is there an API to draw a B-tree in Java? I just dont want to spend much time reinventing the wheel. I am not having trouble with the algorithm per si, mine works perfectly fine after a lot of reading (specially Lafore's Data Structures & Algorithms in Java), I just dont know how to print a B-tree in ...

What is causing this MySQLSyntaxError exception?

Hi all, i written this query (in java class) to select some information from the MySQL database and view it on jsp page... SELECT instructor.name FROM instructor,section,teach WHERE teach.student_id='3'AND teach.section = section.number AND section.instructor_id= instructor.ID but there is exception was occur! javax.serv...

how jvm handles creating object inside a loop

List list = new ArrayList(); String[] test = {"ram", "mohan", "anil", "mukesh", "mittal"}; for(int i =0; i < test.length; i++) { A a = new A(); a.setName(test[i]); list.add(a); } How JVM handles creation of object a in each loop? How "list" differntiate between different instance? Is it good practice to create object on e...

How to format tabular data as text in Java?

I would like to produce nicely formatted tabular text from arbitrary dataset object models. Is there a good library to do this in Java? Specifically, I want output that is formatted like command line data management tools such as the CLI for mysql. Example: +---------+--------------+------+-----+---------+-------+ | Field | Type ...

DateChooser cannot change to selected date visuallly in smartgwt

I am using DateChooser in my project.In that after selecting some other date the dateChooser remains in same date(in current date).It is not changing visually.I tried with setData() and redraw() method's also.Still it is not working.I am using smartgwt-1.1 and gwt-1.6.4 version.My sample code is : final DateChooser dateChooser = new Dat...

How to Represent Classes in an Abstract Syntax Tree Based Interpreter

I have read the related questions, but none of them appears to address the question directly. I am working on writing a PHP script interpreter. I have the AST generating proper nodes for everything except classes. Handling classes is a bit different than handling functions, so I am looking for how to handle classes that are standalone...

Solution for Parameterized Tests

I'm familiar with the use of Parameterized tests in JUnit, e.g: http://junit.org/apidocs/org/junit/runners/Parameterized.html but I wondered whether there were any alternative (possibly better) approaches to externally defined test data. I don't really want to hardcode my test data in my source file - I'd prefer to define it in XML or...

NamespaceContext and using namespaces with XPath

Resolving an xpath that includes namepsaces in Java appears to require the use of a NamespaceContext object, mapping prefixes to namespace urls and vice versa. But I can find no mechanism for getting a NamespaceContext other than implementing it myself. This seems counter-intuitive. Is there any easy way to acquire a NamespaceContext ...

How to access domain properties from a controller in Grails?

I have the following Grails domain class: class Product { String name Float basePrice Category category String image = "default.jpg" static constraints = { name(size:3..25, blank:false) basePrice(scale:2, nullable:false) category(inList:Category.list(), nullable:false) image...

How to run a selected set of unit tests in Eclipse with one mouseclick?

I want to create a launcher/run configuration which runs only the JUnit tests in a selected set of test classes or selected set of packages. Now it looks like I'll have to create separate run configurations for each of my packages containing the tests I want to run. I also have a recollection of this working in older versions of Eclipse....