Hello.
I want to add at runtime a new RuntimePermission to the set of already existing permissions (java.policy) file.
Here is my code:
ProtectionDomain domain = MyClass.class.getProtectionDomain();
final PermissionCollection domainPerms = domain.getPermissions();
Enumeration<Permission> oldPerms = domainPerms.elements()...
Hello!
I have two different-sized monitors, connected together using (I believe) TwinView.
I tried
System.out.println(Toolkit.getDefaultToolkit().getScreenSize());
and get
java.awt.Dimension[width=2960,height=1050]
which is true if you count both monitors together.
Instead of this, I would like to be able achieving one of the fo...
Hi All,
In "THE Java™ Programming Language, Fourth Edition" By Ken Arnold, James Gosling, David Holmes, its mentioned that:
paragraph: (4.3.2)
"Similarly, if an interface inherits more than one method with the same signature, or if a class implements different interfaces containing a method with the same signature, there is only one su...
Can anyone give me a hand with a touch of regex?
I'm reading in a list of "locations" for a simple text adventure (those so popular back in the day). However, I'm unsure as to how to obtain the input.
The locations all follow the format:
<location_name>, [<item>]
[direction, location_name]
Such as:
Albus Square, Flowers, Traffi...
Somewhat related to this question, but in the absence of any answer about QuickBooks specifically, does anyone knows of an address parser for Java. Something that can take unstructured address information and parse out the address line 1, 2 and city state postal code and country?
...
In an attempt to see if I can clean up some of my math code, mostly matrix stuff, I am trying to use some Java Generics. I have the following method:
private <T> T[][] zeroMatrix(int row, int col) {
T[][] retVal = (T[][])new Object[row][col];
for(int i = row; i < row; i++) {
for(int j = col; j < col; j++) {
r...
I have made a custom component (derived from JComponent) which represents
a draggable Bezier-curve.
(looks like a hanging cable, someone might know it
from Bender or Cubase)
My problem is: The curve may become really long,
let's say from top left to bottom right corners of the desktop.
This makes Swing's repaint functionality inefficie...
Does anyone have code to detect duplicate JARs in the classpath?
Background: When there are two versions of the same JAR in the classpath, really strange things can happen. This can even happen when using tools like Maven: Change a dependency and build the WAR without cleaning first. Since target/webapp/WEB-INF/lib wasn't cleaned, the d...
class ApplicationContext{
private final NetworkObject networkObject = new networkObject();
public ApplicationContext(){
networkObject.setHost("host");
networkObject.setParams("param");
}
public searchObjects(ObjectType objType){
networkObject.doSearch(buildQuery(objType));
}
}
class NetworkObjec...
It has been suggested that in order to improve performance of our system that the use of lazy loading should be used across the board. That is to change the OneToOne mapping with the “mappedBy” property to the @OneToMany mapping. This is to address and stop the loading of unwanted data from the database which leads to slowness of the a...
I'm trying to find the best way of parsing the response from a "normal" (i.e. not using the API) Google Maps page in my java code.
Reason: I want to submit a query string requesting a listing (be it hotels, restaurants etc.) and then parse the JSON that comes back. I had looked into using the Google Maps API, but it doesn't seem to cov...
Hi,
If a similar question is already posted on stackoverflow, pls just post the link.
What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ?
The Java API says -
- If its not implemented then it will throw java.io.NotSerializableException.
That's because of the following code in ...
I am in the design phase of a file upload service that allows users to upload very large zip files to our server as well as updates our database with the data. Since the files are large (About 300mb) we want to allow the user to limit the amount of bandwidth they want to use for uploading. They should also be able to pause and resume t...
I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. Oddly enough, I can buil...
I'm hoping to find a simple library that can take a series of 2 dimensional points and give me back a larger series of points that model the curve. Basically, I want to get the effect of curve fitting like this sample from JFreeChart:
The problem with JFreeChart is that the code does not provide this type of api. I even looked at the ...
I've context.xml in my web/meta-inf/ folder containing database connection (pool) details. Now i want the database details for my application to be provided by end user in some properties file and context.xml reading the db connection info from the properties file instead of hard coing them in the file directly.
is it possible for tomca...
I have a big file, it's expected to be around 12gb.
I want to load it all into memory on a beefy 64bit machine with 16gb ram, but I think Java does not support byte arrays that big:
File f = new File(file);
long size = f.length();
byte data[] = new byte[size]; // <- does not compile, not even on 64bit JVM
is it possible with Java?
Th...
How can I read inputs (letters, numbers) from my file.txt wherein it reads infinitely but only stops when it encounters special symbols? At the same time when it is numbers i.e
123,345,abc
it should translate the ascii code and add the 2 values that results as 123 + 345 = 468
EDITED QUESTION
Here's my code; I really had a problem wi...
Looking at the last JUnit test case I wrote, I called log4j's BasicConfigurator.configure() method inside the class constructor. That worked fine for running just that single class from Eclipse's "run as JUnit test case" command. But I realize it's incorrect: I'm pretty sure our main test suite runs all of these classes from one proces...
I have 2 tables:
Movies:
movieID
Users:
userID
These tables have a many to many relationship through the Queue table, with
an additional attribute, listOrder:
Queue:
movieID,
userID,
listOrder
I'm attempting to model this using EclipseLink, but am getting an
"incompattible mapping" error. Here is a sampling of my code:
@...