java

With Maven, how can I build a distributable that has my project's jar and all of the dependent jars?

I have a project (of type 'jar') that (obviously) builds a jar. But that project has many dependencies. I'd like Maven to build a "package" or "assembly" that contains my jar, all the dependent jars, and some scripts (to launch the application, etc.) What's the best way to go about this? Specifically, what's the best way to get the ...

Ant+Junit works on first run and never again.

Hey guys I've been trying all day to get an ant file to automatically build my project. The file (appended below) was on a web page I found and is pretty thorough. My problem is that it works as long as I don't run the "clean" target. Once the I run the "clean" target the "test" target ceases to work. I get NoClassFound errors on all te...

JTable that can save to a file

Does anyone know of a JTable based Swing component OR code example that can save to a file? i.e: provides a menu item or button that when clicked on prompts the user for a file location and saves the table's contents to a file (CSV, XLS, TXT, or whatever). The easy part is looping through the rows and saving to a file. But there also ne...

Can Eclipse be configured to disable warnings for derived source files?

I am using ANTLR to generate Java source files. I can make Eclipse understand the generated files are derived, but it still gives me warnings about harmless things (e.g. unnecessary imports and so on). I would like to configure Eclipse to ignore derived files when showing warnings. Is this possible? ...

Using JNDI for Database connections

This might sound like a noob question but this is the first time I'm treading into Database territory. From here I got the info that The most efficient way to implement communication between the server and database is to set up a database connection pool. Creating a new connection for each client request can be very time-c...

Configuring container-based authentication with alternative digest methods

Following up on a prior question, I'm trying to figure out how to set up container-based authentication for a J2EE application. Specifically, I need to be able to apply a password digest algorithm other than the ones supported by the java.security.MessageDigest (which are SHA, MD2, or MD5 - here's where I think that limitation is documen...

Is there a way to dynamically get an xpath of an element during runtime in Selenium

Is there a way to return the xpath of an element in Selenium during runtime whos xpath changes every time you return to the page? I need to extract a random number from the xpath of the element. Ex: //div[@id='element_id-87462'] where 87462 is a new random number everytime the element is loaded. I want to be able to extract 87462 so I...

How can I connect to a web based Oracle database with Java?

I have an account, password and the URL. ...

java security manager

grant { permission java.io.FilePermission "C:\\class\\*", "read, write"; permission java.lang.RuntimePermission "createClassLoader"; }; My policy.txt java.security.AccessControlException: access denied (java.io.FilePermission c:\class read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java...

Hot Deploy of development changes with Eclipse, Tomcat, and Jetspeed

Hi, I am developing a Jetspeed portal application running on Tomcat, using the Eclipse IDE with the Sysdeo Tomcat launcher plugin to enable debugging of the application running in Tomcat/Jetspeed. I was wondering how to enable hot deploy of development changes for this environment? Does anyone know how to configure a Jetspeed portal web...

Trigonometry in CLDC 1.0 / MIDP 2.0 application

How can I use trigonometry in CLDC 1.0 / MIDP 2.0 application? I need "sin cos tan asin acos atan atan2" functions from standart Math library. Thanks ...

How to instantiate a shared resource in JUnit

I noticed that jUnit runs the constructor of my test class for each method being tested. Here's an example: public class TestTest { protected BigUglyResource bur; public TestTest(){ bur=new BigUglyResource(); System.out.println("TestTest()"); } @Test public void test1(){ System.out.printf("test1()\n"...

What's a good place to save a file to in a Java app?

Hello I have a Web Start application which needs to save a single text file. I would like to know where I should write the file, such that it goes in a tidy place regardless of the platform it runs on. If I get my filepath like this... new File(System.getProperty("user.dir") + System.getProperty("file.separator") + "test.txt); ... t...

Registering multiple keystores in JVM

Hello, I have two applications running in the same java virtual machine, and both use different keystores and truststores. A viable option would be use a single keystore and import all the other ones into the shared keystore (e.g. keytool -import), but it would really help my requirements if I could use separate keystores for separate ...

Using Java Lib with Scala Reserved Words

Hi, I'm using an external library written in java (selenium). One of the function calls has signature type(String,String) , and I keep getting compiler errors when trying to call it from scala, i.e.: selenium.type("ab","abc") Is there any workarounds for this issue? Thanks, ...

Java Instance Variables vs Local Variables

Hi, I'm in my first programming class in high school. We're doing our end of the first semester project. This project only involves one class, but many methods. My question is best practice with instance variables and local variables. It seems that it would be much easier for me to code using almost only instance variables. But I'm not ...

Eclipse throwing ClassNotFoundException despite me having added the proper Apache POI .jar File ?

I'm using a servlet to upload .xls (Excel Spreadsheets) files to the server. I'm using the Apache FileUpload API for the upload portion of the business logic, to ensure weather this part is working, I have successfully attempted uploading a .txt file to the Servlet after which -- the Apache FileUpload API, from the servlet side gives me ...

Storing java objects in server memory

Hi all, I got a java web project handling several objects (again containing n objects of type A (e.g. time and value) and m objects of type B (e.g. time and String array)). The web projects itself contains several servlets/jsps for visualization as well as some logic for data manipulation and currently runs on an Apache Tomcat. Is it ...

Java: Try-Catch-Continue?

Let's say I can a set of statements: try { String a = getProperty("a"); String b = getProperty("b"); String c = getProperty("c"); } catch(Exception e) { } Now, lets say property b was not found and the function throws an exception. In this case, how would I just continue or perhaps set b to null without having to write a try-ca...

Where do you define spring bean configuration files

I am separating my spring bean configuration files as follows: myapp-service.xml myapp-servlet.xml However I am getting the error; Error creating bean with name 'beanName' defined in ServletContext resource [/WEB-INF/myapp-servlet.xml]: Cannot resolve reference to bean 'beanService' while setting bean property 'beanService'; nested...