java

Does python have an equivalent to Java Class.forName()?

I have the need to take a string argument and create a class in python. In Java, I would use Class.forName().newInstance(). Is there an equivalent in python? Thanks for the responses. To answer those who want to know what I'm doing: I want to use a command line argument as the class name, and instantiate it. I'm actually programmi...

Number of lines in a file in Java

I use huge data files, sometimes I only need to know the number of lines in these files, usually I open them up and read them line by line until I reach the end of the file I was wondering if there is a smarter way to do that ...

Are static fields open for garbage collection?

Given an hypothetical utility class that is used only in program setup: class MyUtils { private static MyObject myObject = new MyObject(); /*package*/static boolean doStuff(Params... params) { // do stuff with myObject and params... } } will myObject be garbage collected when it is no longer being used, or will it stic...

How to unload dll from java JVM

Hey I need to unload a dll that was loaded with System.loadLibrary(..), anyone know if this is possible? Thanks ...

Calculating difference in dates in Java

Hi, I find it funny that Java (or the java.util library) does not have a built-in function to calculate difference in dates. What is the best way to do this? I know the simple way is to take the difference of the time in milliseconds and then convert that into days. However, i wanted to know if this works in all cases (with daylight sav...

How good is java.util.Random?

Two Questions: Will I get different sequences of numbers for every seed I put into it? Are there some "dead" seeds? (Ones that produce zeros or repeat very quickly.) By the way, which, if any, other PRNGs should I use? Solution: Since, I'm going to be using the PRNG to make a game, I don't need it to be cryptographically secure. I'm ...

What Issues prevent Java applications from working on multiple platforms?

Java is supposed to be "write once, run anywhere" and it really can be, but in some cases it turns into "write once, debug everywhere". What are the most common reasons for problems when moving a Java application from one platform to another? What are un-common but interesting reasons? ...

Can Paradox 4.5 be set up on a server?

I have established a link using Netbeans and Paradox driver and can query the database. Can Paradox 4.5 (Borland) be set up on a server so that the database can be queried remotely? Please point me in the right direction. Thanks! ...

Using ActiveMQ via JNDI

I'm trying to create simply connect with ActiveMQ using JNDI. I have Queue named 'example.A'. According ActiveMQ documentation touching JNDI, if I want to use ConectionFactories and Queues (Topics) via JNDI, I have to place jndi.properties file on my classpath. As I have understood, activeMQ classpath is %activemq%/conf directory by ...

Best spell checking api for Java

What is the best Java spell checking API? Free or purchased, must be royalty-free. ...

Java's Virtual Machine and CLR

As a sort of follow up to the questions called "Differences between MSIL and Java bytecode?" what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framwork Common Language Runtime (CLR) works? Also, is the .NET framework CLR a "virtual machine" or does it not have the attributes of a vir...

Use Hashtable, Vector or HashMap or ArrayList in Java

One meme that gets stressed with Java development is always use ArrayList over Vector. Vector is deprecated. That may be true, but Vector and Hashtable have the advantage that they are synchronized. I am working with a heavily concurrent oriented application, wouldn't it benefit to use objects that are synchronized like Vector? It se...

How to: Java listening for events captured by C thread.

I would like to create a Java program to listen for and respond to events captured by a thread in C. Can someone explain how this can be achieved using JNI, or point me to online tutorials? Thank you. ...

How can I profile a JNI application using the Eclipse TPTP?

I need to profile a java application launched by the JNI invocation API from a C application, and naturally the TPTP tools seemed like a good place to start. However, I can start the application, but I have no idea how to connect to it for profiling. I realize this falls into the 'dumb newbie' bucket, but I really am kind of lost. Per...

How can I determine what roles are required to access a URL with Spring Security?

I'm using Spring Security to secure a webapp. The URLs are secured like this: <security:http entry-point-ref="authenticationEntryPoint"> <security:intercept-url pattern="/" access="ROLE_ANONYMOUS" /> <security:intercept-url pattern="/assets/**/*" access="ROLE_ANONYMOUS" /> ... <security:intercept-url pattern="/**" access="ROLE_U...

seam-gen, netbeans and completion

How can I make seam-gen work with NetBeans 6.5 so that completion of tags (s:, ui:, rich:, ...) works? In the free-form project that seam-gen creates, this does not seam to work. If I create a standard NetBeans web application (File -> New Project), completion does work though. Thanks, m. ...

Dynamic throtlling off an ActiveMQ message queue with Camel

I am an ActiveMQ / Camel noob with a specific scenario in mind, I wonder firstly if it is possible and secondly whether someone might provide a little direction. Basically I need to perform dynamic throttling off the queue. I.E the ability to set at runtime the rate a particular group of messages will be consumed from the queue. So I m...

Invoke Python modules from Java

I have a Python interface of a graph library written in C - igraph (the name of library). My need is to invoke the python modules pertaining to this graph library from Java code. It goes like this, the core of library is in c. This core has been imported into Python and interfaces to the functions embedded in core are available in Python...

Timed popup in Android

I am creating a matching game for Android, and when the user gets a match, a dialog box should pop up saying "Match!" I cannot figure out how to do this though. If I use Thread.currentthread().sleep, the dialog never appears. android.app.AlertDialog a = new android.app.AlertDialog.Builder(match.this).setTitle("Match!").show(); Thread.c...

What are synchronizing strategies for Prevayler?

Prevayler guarantees that all the writes ( through its transactions) are synchronized. But what about reads? Is it right that dirty reads are possible if no explicit synchronizing is used (in user code)? Are they possible if a business object is read as: // get the 3rd account Accont account = (Bank)prevayler.prevalentSystem().getAc...