java

What are the main Skills to be a Performance Consultant?

If I want to become a Performance Consultant for Java applications and systems, what are the main skills I need? long experience with Java itself using a Profiler (or StackShots) database knowledge (to avoid/detect common performance mistakes : indexes...) Caching library Java concurrency Do you agree on the importance of these? What...

Java executing commands in Operating System

I have a Java program that executes specific commands into the OS. Am also using Process.waitfor() as showing in the code below to indicates if the execution completed successfully or failed. My question is, is there any other way to avoid using process.waitfor(), Is there a way to use while loop and perform certain action until the pr...

What is the proper way of disabling an OSGi service at service start?

I have created an OSGi bundle with an exposed (declarative) service. If I, when activate is called, notice that something is amiss such that I can not provide the service, I need to prevent it from being exposed. At the moment the activation function looks like so: public void activate(ComponentContext context, Map<String, Object> prope...

Error when deploying WAR to WebSphere Portal environment

Hi I'm trying to deploy an out-of-the-box portlet to my WebSphere Portal 6.0 environment. I have made minor HTML changes one of the JSPs and any subsequent deployment results in the following errors: EJPAQ1316E: Could not process the selected file from the browse button as a WAR file. Make sure it is a WAR file and try again. com.ibm...

Open source alternative to JavaRebel?

Is there an open source (and ideally free software) alternative to ZeroTurnaround's class reloading tool Java Rebel? ...

Writing Unittest for generic classes... best approach?

Hello! I'm supposed to write unit tests for a project whose code another colleague has written. He created a generic list class. Now i'm thinking about, the best way to create the unittests for the class and how to avoid much repetitive code. The List class can be instaniated with String, Integer and some other Types. How can i avoid to ...

Server-client Java distributed application

Hi to all, I have to design a distributed application composed by one server (developed in Java) and one or more remote GUI clients (Swing application with windows). As stated before the clients are Swing GUI application that can connect to the server in order to receive and send data. The communication is bidirectional (Server <=> Cli...

concurrent queue - general question (description and usage)

Hello, I am having some trouble grasping the idea of a concurrent queue. I understand a queue is a FIFO, or first come first serve, data structure. Now when we add the concurrency part, which I interpret as thread safety (please let me know if that is incorrect) things get a bit fuzzy. By concurrency we mean the way various threads can...

dom doc to string

I have a method in java that has 2 String parameters and it writes string to a file, now I have dom doc that holds value that I need to write to a file but its not string type, how can I convert it to a string here is my code : import java.io.*; import org.w3c.dom.*; import org.xml.sax.*; import javax.xml.parsers.*; import javax.xml.tr...

Design Pattern rich code base ?

Am new to design patterns, could you recommend a open code base (preferably in java) that has design patterns used explicitly and elegantly. Reading up GOF has left me confused am looking for a project that used a few patterns that interacted with each other. thanks. ...

Beginner: Assigning values to arrays in Java

I am attempting to write a simple Genetic Algorithm in Java after reading a book on Machine Learning and have stumbled on the basics. I'm out of practice with Java so I'm probably missing something extremely simple. Individual public class Individual { int n; int[] genes = new int[500]; int fitnessValue; public int ge...

How to automatically create and inject a proxy of a missing dependency?

Given the following classes: package com.acme; public class Foo { private Bar bar; public void setBar(Bar newBar) { this.bar = newBar; } } @AcmeService public interface Bar {} and a Spring configuration file of: <beans> <bean id="foo" class="com.acme.Foo"> <property name="bar" ref="bar" /> </bean> </beans> when ...

How do I get ddsteps to insert Date & Time values in its test data sets?

Currently I am using DDsteps as a datadriven testing framework for my unit tests. It works quite well, except when inserting DateTime data into the database. Example data input row (stored in excel): APS_ID99${my.unique_four_digits} APS_LOGIN_DT3/21/2007 8:52 DDsteps will generate this SQL to load the date time field: insert...

Benefits of MessageFormat in Java

In a certain Java class for a Struts2 web application, I have this line of code: try { user = findByUsername(username); } catch (NoResultException e) { throw new UsernameNotFoundException("Username '" + username + "' not found!"); } My teacher wants me to change the throw statement into something like this: static final Strin...

java -version returns old version

OS: Windows XP I am using yuicompressor-2.4.2 to compress some css before uploading to my server. But when i run it, the following exception appears: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/yahoo/platform/yui/compressor/Bootstrap (Unsupported major.minor version 48.0) So I think it's beacause of the JRE...

How to call an EJB from another EJB ?

I use jboss-IDE. so, I created a project with many EJB's in the same project. now, I need a functionality exposed by EJB A in EJB B. so, I need to call EJB A in EJB B. How do I do that ? P.S : dealing with EJB 2. ...

Plagiarism Analyzer (compared against Web Content)

Hi everyone all over the world, Background I am a final year student of Computer Science. I've proposed my Final Double Module Project which is a Plagiarism Analyzer, using Java and MySQL. The Plagiarism Analyzer will: Scan all the paragraphs of uploaded document. Analyze percentage of each paragraph copied from which website. High...

Hibernate custom UserType isn't working

I've created a UserType (see below) to handle a situation in our mySQL database where we've been saving null dates as 0000-00-00 00:00:00. When I try and persist my entity with a null for dispDT (see below) it generates this exception: "javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property refer...

Showing TIFF images in Java

Hi! Someone can tell me how to load a multipage TIFF image in Java and show it in a JScrollPane? Which class can I use? ...

Doubt with List<Generic> Explicit Cast

I don't understand why in some cases I can make an explicit cast and in other cases I can not. Thanks to all! //DAreaLabel extends Message //This Code Works List<Message> list1 = (List<Message>) Arrays.asList((Message[]) getPageRecords(getClasspath(), methodName, object)); DAreaLabel areaLabel = (DAreaLabel) ((List<M...