java

Change Java package name in a SVN branch

I currently have a java library in subversion under package: com.company.product.foo.* Unfortunately, I have to refactor this into: com.othercompany.bar.* That'd be fine as a one-shot. But this has to be performed only on a specific branch. The problem is then to merge changes from trunk to the branch with totally different names. ...

Java public static main()

I am learning Java, theres one thing I do not understand.. in the main routine: public static void main(String[] args) { I think I pretty much understand this, in the language I know, I think it would be like this: public static function main(args:String):void { The first thing I do not understand is what are the 2 brackets [] for...

How do you determine if a file is html from the URL?

Given a URL, how can you tell if the referenced file is and html file? Obviously, its an html file if it ends in .html or /, but then there are .jsp files, too, so I'm wondering what other extensions may be out there for html. Alternatively, if this information can be easily gained from a URL object in Java, that would be sufficient ...

JSP Display Tag Sorting Page Reload

Setup: I have a Struts web application where I use displaytag elements to do all of my table work. Each column is sortable. Situation: When I click sort, on a long page, it sorts, but drops you at the top of the page. Question: How do I use an anchor or some other method to come back to the table rather than the top of the page. Additio...

display tags jsp tags

i am using diaply tags library for displaying my tables.But i cant use the <% %> tagst there.If i try to us it it gives me error.but i can use tag there. If i try to use followin code in my jsp it give an error sayin shoul hav a matcheing ending tag. i have follown java code in jsp List<Course> = (List<Course>)request.getAattribute("c...

Error reading configuration file for JAAS Authentication Provider in Spring

Really ripping my hair out on this one. I have a JAAS Authentication Provider configured for my Spring webapp. I've created a bean definition for it as follows: <beans:bean id="jaasAuthenticationProvider" class="org.springframework.security.providers.jaas.JaasAuthenticationProvider"> <custom-authentication-provider /> <b...

How to Set the Background Color of a JButton on the Mac OS

Normally with Java Swing you can set the background color of a button with: myJButton.setBackground(Color.RED); which would cause the button to be red. But on the Mac OS, this method seems to be ignored. The button just stays the default color. How can the color of a JButton be set on the Mac OS? ...

CSS Files Don't Refresh with Wicket (Launched in Intellij via Start.java)

I have create a skeleton Wicket project using mvn archetype:create -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.4-rc4 -DgroupId=com.mycompany -DartifactId=myproject All the configuration/importing new project with Maven/Intellij worked fine. I proceeded to add a basic CSS ...

Android 1.5 Programming with TabHost and Buttons?

Hello All, I am currently trying out the android sdk 1.5 and i have seen a couple of examples on TabHost what i am trying to do is to use a different button on each Tab to do its tasks. What i tried was using onClickListiner() and onClick() i think this is what all the developers use but i keep getting a null exception on the log cat, ...

long http close time in PS3

Hi All, I’m currently working on a project to develop an application for PS3 using BD-J. BD-J is very similar to Java J2SE1.3. I use HttpURLConnection to download content. The skeleton code is as follows HttpURLConnection inputConnection = (HttpURLConnection)effectiveUrl_.openConnection(); inputConnection.connect(); BufferedInputStre...

How do you stub an individual method in java for unit testing?

I've got a method in a class that's writing to some string, which calls another method which does the same. Something like: void foo() { a += "xyx"; bar(); } void bar() { a += "abc"; } For unit testing purposes, I want to test foo and bar separately. Is there any way to prevent bar from being run when I call foo() or to replace...

Unable to get the content out of a HttpServletRequest

Hi, I'm trying to get the contents of a HttpServletRequest. Here is how I'm doing it: // Extract the request content StringBuilder stringBuilder = new StringBuilder(); BufferedReader bufferedReader = null; String content = ""; try { InputStream inputStream = request.getInputStream(); if (inputStream != null) { bufferedReader = new...

MySQL Inserting large data sets from file with Java

I need to insert about 1.8 million rows from a CSV file into a MySQL database. (only one table) Currently using Java to parse through the file and insert each line. As you can imagine this takes quite a few hours to run. (10 roughtly) The reason I'm not piping it straight in from the file into the db, is the data has to be manipula...

use cases for well-known Java software packages

I am browsing some of the Java software packages (Guice, GWT, JAX-RS, etc.) and my head is spinning quite a bit because I don't really know the use cases when these particular software packages shine. The tutorials seem to show you how to do something with their package, but not why you would want to use their package (or in which cases ...

How to read a single char from the console in Java (as the user types it)?

Is there an easy way to read a single char from the console as the user is typing it in Java? Is it possible? I've tried with these methods but they both wait for the user to press enter key: char tmp = (char) System.in.read(); char tmp = (char) new InputStreamReader(System.in).read (); char tmp = (char) System.console().reader().read()...

Java - Parse a Multi-delimited/dimensional String

I have the following string with separate delimiters that needs to be parsed out and I am running into a bit of a wall at the moment. example: category 1---category 2;subgroup 1||subgroup 2---subgroup 1;value 1||value2---value 3 I wanted to re-arrange into the following grouping: category 1;subgroup 1;value1;subgroup 2;value 2;catego...

Is there a such thing as a while each loop in Java?

If there were such a thing I would imagine the syntax to be something along the lines of while(Integer item : group<Integer>; item > 5) { //do something } Just wondering if there was something like this or a way to imitate this? ...

Discover the class of a methodinvocation in the Annotation Processor for java

I am writing some tools for our build system to enforce some strict calling conventions on methods belonging to classes containing certain annotations. I'm using the Compiler Tree API... What i'm wondering is when traversing the 'tree', how can you tell the type of class/interface for a MethodInvocation. I'm subclassing TreePathScan...

Possible problem with Mac OSX udpate 10.5.7 and swingUI

We just updated to Mac OSX 10.5.7 and now anytime I bring up any of my SwingUI based dialogs our application crashes. Literally everything was working fine I just made some good progress on the project and decided to take a break and install the update, I come back boot up the application and discover anytime a swingUI based element com...

Java: iterate through HashMap

What is the best way to iterate through a HashMap? ...