java

java regex line

In java i would like to read a file line by line and print the line to the output. I want to solve this with regular expressions. while (...) { private static java.util.regex.Pattern line = java.util.regex.Pattern.compile(".*\\n"); System.out.print(scanner.next(line)); } The regex in the code is not correct, as i get InputMismatch...

Tomcat and VM

Hi, I really confused in understanding where the tomcat actually runs. Is it execute inside the JVM, which execute servlets. Or it has it's own VM in executing servlet or JSP. Thanks in advance. ...

How do I suppress all checks for a file in checkstyle?

I'm doing an override for a third party class and I want to suppress all checks for it (since I'm only keeping it around until the patch is accepted). Is there a way to suppress all checks for a file? I tried using "*" but that fails. ...

What's wrong with this HQL? "No data type for node"

session.createQuery("Select attribute from GoodsSection tgs " + "join gs.ascendants ags join ags.attributes attribute " + "where attribute.outerId = :outerId and tgs = :section ") .setString("outerId", pOuterId) .setEntity("section", section) .setMaxResults(1) .uniqueResult(); Looks fine to me, but the result is java.lang.Ille...

Can I pass arguments to the GWT compiler?

With the GWT compiler, is it possible set pass in properties as arguments to the GWT compiler? I know you can pass in certain defined parameters such as -war and -style, but this is for passing in property values, such as "user.agents" or "locale". From what I can see of the documentation, the properties can only be set using from with...

Does NTEventLogAppender work on Windows Server 2008?

I can't find any reference to what versions of Windows the log4j NTEventLogAppender is supported on. I am specifically interested in whether it works on Windows Server 2008. ...

Running UNIX commands as different user, from Java

Trying to write a Java program capable of running a UNIX command as a different UNIX user. I have the user's password, and I know the command I want to run, but the command has to be run as that user - so I have to login as that user first. For example: say we have a user, jim, who wants to see what's in bob's home directory, and (for w...

Hibernate Unidirectional Parent/Child relationship - delete() performs update on child table instead of delete

If I delete a record from the Parent table I want the corresponding records in the child table to be deleted. How can I make Hibernate delete from the Child table rather than attempt to update with a null? I'm using Hibernate 3 but cannot use annotations at this time. I've attached copies of HBM, DAO etc below. -- Thank you in Advance...

OSGi felix: Sharing a class between the host application and a bundle possible?

Hi there! Inside my host application I tried implement a simple pushService, which shall be used to transfer an instance of a class named Vehicle to the OSGi world, by providing a set and get method. To be able to use the service I exported both the service interface and the Vehicle class to a jar file and imported that file within the ...

Converse of java FileDescriptor .sync() for *reading* files

Reading the javadoc on FileDesciptor's .sync() method, it is apparent that sync() is primarily concerned with committing any modified buffers back to the underlying storage. I.e., making sure that anything that your program has output will actually make it to the disk (or socket or what-have-you, but my question pertains mainly to disks)...

Java JUnit assertEquals with Long

assertEquals( new Long(42681241600) , new Long(42681241600) ); I am try to check two long numbers but when i try to compile this i get integer number too large: 42681241600 error. Documentation shows there is a Long,Long assertEquals method but it is not called. ...

Programmatic use of Spring Security

I am using Wicket with the Wicket Auth Project for my presentation layer and I have therefore integrated it with Spring Security. This is the method which is called by Wicket for authentication for me: @Override public boolean authenticate(String username, String password) { try { Authentication request = new UsernamePasswordAu...

Accessing NexusDB from Java

I am trying to get info from an embedded db called NexusDB using java. Alternative 1: I've read in NexusDB website that there is an ODBC driver so I might use it with unixODBC. Then I need to do a JDBC-ODBC Bridge as stated here. Alternative 2: Get some sort of application to migrate NexusDB db to another db. Would like to know one. ...

Detecting/controlling a process

I have a java application where I want to check to see if an application is running. If it is not running, I want to start it. If it is running, I want to kill it and then restart it. Can someone tell me how to do this? I can start/stop the program easily enough, with the ProcessBuilder. But I cannot detect a process that is already...

Make a wizard like application in Android

Which you think is the best way of doing a wizard like application (user can navigate between screens with a next and back button, and each screen has to save some state data) in Android platform. I mainly can think in two approaches: Having one activity+view for each screen and then i make the screen switch by calling each activity. ...

After calling JTabbedPane.removeAll(), the JTabbedPane still has x number of tabs?

In my JTabbedPane, I am removing tabs in 2 different ways: tabbedPane.remove(index) and tabbedPane.removeAll() Both work fine in terms of closing the tabs. However, I have a change listener on my TabbedPane that calls back to another module to report on tab changes. This is where the problem is. When adding and removing tabs usin...

How to get several regex groups from Matcher in Java?

I have a Java program that does some String matching. I'm looking for anything that matches \d+x\d+ in a String. This works, using the Pattern and Matcher classes. However, to parse the String parts I have found, I have to manually parse the String I get from the Matcher.find() and Matcher.group(). How can I tell the Pattern I'm looking ...

Why is the solution like this?

From Java Malik textbook- determine if an number is divisible by 11.. Code Solution provided: import java.util.*; public class Divby11 { static Scanner console = new Scanner(System.in); public static void main (String[] args) { int num, temp, sum; char sign; System.out.print("Enter a positive inte...

Communication between Java and Javascript without Netscape or IE?

In the lab I work in, we use Mozilla 1.7 for Sun Java™ Desktop System and Firefox 2.0.0.4. My goal is to modify an existing Java application (run via executable jar) to communicate with our web-based login system. I am open to the idea of using both Java Applets and JavaScript to accomplish this task, but I have not found a way to inte...

Is it possible to explicity tell maven to download and install an artifact to the local repository?

Yes I read http://stackoverflow.com/questions/884808/ and other related questions, but I don't want to install the file manually. Actually I want to have something like a wget for maven, which fetches an artifact (with dependencies) and puts it somewhere or installs it in the local repository. Is the maybe a plugin available which does t...