When using EntityManager, is it better to get one instance with PersistenceContext and pass it around in my program, or should I use dependency injection more than once?
In my application each client will communicate with a stateful session bean, and each bean needs to use EntityManager at some point.
I guess that bean methods are invoc...
java.util.Locale is one of those classes where I wonder whether I'm too stupid or the guy who wrote it. Is Mark Davis around?
As far as I can see, this class isn't supposed to be used. The internal cache in the class is private. The factory package private. equals() uses == to compare strings. This means that I can't compare instances o...
What is a typical/preferable way to build system with Apache-Camel and ActiveMQ ? How can high availability be achieved ? What container the Camel should run in ?
...
I have two packages in my project: odp.proj and odp.proj.test. There are certain methods that I want to be visible only to the classes in these two packages. How can I do this?
EDIT: If there is no concept of a subpackage in Java, is there any way around this? I have certain methods that I want to be available only to testers and other ...
If I call writeUTF(String) on a DataOutput object, is there a way to tell how many bytes were actually written?
E.g.:
public int write(DataOutput output) throws IOException {
output.writeUTF(this.messageString);
int numberOfBytesWritten = ???;
return numberOfBytesWritten;
}
The only method that comes to mind is to create a ...
I have a test suite class:
@RunWith(Suite.class)
@Suite.SuiteClasses({
GameMasterTest.class,
PlayerTest.class,
})
public class BananaTestSuite {
What annotation do I need to use to make a function in this class run before any of the classes containing actual tests? Right now, I'm doing this, and it works, but it's not as read...
Java newbie. I am trying to run a java main class from cmd line and getting back ClassNotFoundException:
java -cp class c:\development\eclipse\workspace\Library-Manager-Server\bin\demo\rmi\librarymanager\server\LibraryManagerServer
-Djava.security.policy="C:\Development\Eclipse\Workspace\Library-Manager-Server\security.policy"
-Djav...
I think I'm not using verify correctly. Here is the test:
@Mock GameMaster mockGM;
Player pWithMock;
@Before
public void setUpPlayer() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
pWithMock = new Player(mockGM);
}
@Test
public void mockDump() {
pWithMock.testDump();
...
On the commandline
is java -cp simply an abbreviation for java -classpath?
(I seem to remember they may have different behaviour but can't find explicit documentation).
UPDATE Thanks (@AlBlue) for confirming that my memory was in fact correct and that they used to be different.
...
How can a random number be generated from scratch, i.e without using any built-in features of the language / outside API that will help with the randomization process?
For example php has a rand() function and a seed function, and I'm sure java also has some similar stuff.
You can use built-in functions to get the current time etc, but...
What I want to do is implement some basic security by checking not only what class has called a particular method, but also, which instance of that class.
I tried
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
but that obviously only gives me the class name. The problem with allowing/requiring th...
I have used these three open source tools for packaging my java apps, but they all look like abandon-ware now. All three are very good pieces of software. What are the options now? (or is using Java for desktop app development no longer a "hot" market for app developers to build & maintain these tools?).
1) exe wrapper:
jsmooth - no new...
I am trying to create a GUI that will coexist with several images.
There is one background image that will take up the most room.
On top of the background image several other images will be displayed in varying locations.
These locations will be updated every 5 seconds or so, so speed is not a huge factor.
So all I need is the ability ...
Is it possible to store a string and 11 integers in the same object.
Thanks,
Alex
...
I have a Address bean that have a LatLng component. Please tell me how can i project that component and transform it in to a new class.
Thank you.
...
Can XmlJavaTypeAdapter marshal from ClassA object to ClassB object? So that when :
public void createClassB (ClassB b) { }
I can pass in ClassA object. Does it possible?
...
I'm using JAWS to access WordNet. Given a word, is there any way to detect if it is a proper noun? It looks like the synsets have pretty coarse lexical categories.
To clarify, there is no context for the words - they are just presented individually. If a word could conceivably be used as a common noun, it is acceptable. So "mark" is fin...
I looked online and was not able to find a working example of the PopupWindow class. The code examples I found online either compile but do not work, or are using methods which have since been removed (such as Activity.getViewInflate()).
Is there a simple working example that displays a PopupWindow?
...
I would be shocked if this were immediately answered here, as this is a question specific to the Google Calendar Java API, but I'll put it out there anyway.
The tutorials for Google Calendar give a nice explanation of Calendar Insertion as well as Event Insertion. However, I would really like to create a calendar on my server, add even...
Hi,
I have this xml data format. I would like to extract the properties name and value from it. I have tried to get node by node but it is troublesome.
<?xml version="1.0"> encoding="ASCII"?>
<xDiagram>
<children iD="1261435145010.0" location="Point(547,184)"
size="Dimension(102,140)" shapeType="TestInfoShape"
modelEntity...