java

Are there any other Image sub classes?

I was wondering if there are any implementations of java.awt.Image out there other than the ones provided by the Java standard edition. Any third party classes maybe that provide any useful features overlooked by Sun? ...

How can I make a java FileDialog accept directories as its FileType in OS X?

I am trying to switch from using a JFileChooser to a FileDialog when my app is being run on a mac so that it will use the OS X file chooser. So far I have the following code: FileDialog fd = new FileDialog(this); fd.setDirectory(_projectsBaseDir.getPath()); fd.setLocation(50,50); fd.setFile(?); fd.setVisible(true); ...

Modifying a file inside a jar

I would like to modify a file inside my jar. Is it possible to do this without extracting and re jarring, from within my application? File i want to modify are configuration files, mostly xml based. The reason i am interested in not un jarring is that the application is wrapped with launch4j if i unjar it i can't create the .exe file a...

JAXB: Can I make XmlAttribute's parameter "required=true" to default?

Hello! I have @XmlAttribute(required=true) in hundreds places in a projects. Can I make this default?... ...So that I then only need to specify @XmlAttribute(required=false) when needed. ...

Java - Extract strings with Regex

I've this string String myString ="A~BC~FGH~~zuzy|XX~ 1234~ ~~ABC~01/01/2010 06:30~BCD~01/01/2011 07:45"; and I need to extract these 3 substrings 1234 06:30 07:45 If I use this regex \\d{2}\\:\\d{2} I'm only able to extract the first hour 06:30 Pattern depArrHours = Pattern.compile("\\d{2}\\:\\d{2}"); Matcher matcher = depArrHours...

Welcome file chosen based on assigned roles (Java web app)?

I have a Java web application running on JBoss using JAAS for authentication. I would like to dynamically select the page a user logging in is shown based upon their roles as I have disjoint sets of users that shouldn't have access to the same pages. I've tried using a Filter, but Tomcat denies access (correctly) to the requested URL be...

java convert string to HTML string

Is there a way to convert a string to a string that will display properly in a web document? For example, changing the string "<Hello>" To "&lt;Hello&gt;" ...

Problem with matching token in a line, using Scanner in Java

Hello, I need to match certain things from lines of an input text. The lines look like this: to be/ Σ _ Σ [1pos, 1neg] {0=1, 2=1} I am using the Scanner class to read each line of the text, and I have written the following code. However, something is not working properly, because the patter "to" is not matched against the line, and...

How to measure the needed size for a button in Java

I need to make a button that will display different things depending on the state if the app. So for example if nothing has been opened its title will be "Lesson Plans" and if project B is open it will be "project B Lesson Plan", I am using the java.awt.Button class for this. My question, is there a way to determine how big the button ...

Java Sudoku Gui

Hey stackoverflow. I am currently writing a sudoku solver in java. What i need now is some kind of swing gui to input the already known numbers. I created a jframe but manually adding 81 textfields from the toolbox seems like a bad solution. I am also able to add the with something like this: this.setLayout(new GridLayout(9, 9)); ...

Java FileWriter

I'm currently using FileWriter to create and write to a file. Is there any way that i can write to the same file every time without delete the contents in there? fout = new FileWriter( "Distribution_" + Double.toString(_lowerBound) + "_" + Double.toString(_highBound) + ".txt"); fileout = new PrintWriter(fout,true); fileout.pr...

Mac OS X: Setting up Xcode to use Ant results in permission errors

I'm trying to setup Xcode as my primary IDE to work with our existing projects but running into some permissions problems. Our projects are java based and we use ant to build the jar and it all runs under Tomcat. Up until now, I have been working strictly from the terminal and a text editor. This has been working fine, but I'm trying t...

Which J2EE server should I use?

OK, this is a little unusual, because ANY J2EE container can do the simple things I want to do (XML processing, JPA, Hibernate, SOAP/REST web services, etc). This is for personal use, more to gain skills than to accomplish essential functionality. I have my own Linux server (Ubuntu Jaunty x86_64) with business class internet, so I can ...

Connecting to an NTP server keeps failing (Java)

I'm just learning how to do networking in Java and the first simple example of getting the time from an NTP server keeps throwing a ConnectException. I'll copy and paste the code, but I have the feeling it must be something not code related since this code came out of a book. import java.io.*; import java.net.*; public class AskTime { ...

tomcat className="org.apache.catalina.authenticator.SingleSignOn" real example?

1.I came across decumentation on this,but cannot find real example on how to use ? any tutorial on this? 2. is there any sample war that i can try out on this? ...

How does google app engine sandbox work?

How does google app engine's sandbox work? What would I have to do to create my own such sandbox (to safely allow my clients to run their apps on my engine without giving them the ability to format my disk drive)? Is it just class loader magic, byte manipulation or something? ...

Google App Engine "repackaged" package

What is the purpose of the classes in this package? I want to use Base64 encoding in my app. As I'm typing away in Eclipse, I am prompted if I want to import a class called "com.google.appengine.repackaged.com.google.common.util.Base64" I can't find any documentation about what this class does. No javadoc, or no mention in the Google A...

Avoiding tomcat status report

Hi there, I am trying to return a 401 error code from a webapp to trigger a basic authentication process, but tomcat is hijacking the response to display its status report page. Is there a way to prevent tomcat from doing this and let the error code go all the way to the browser? UPDATE My mistake: I forgot the WWW-Authenticate header ...

Most efficient way to create InputStream from OutputStream

This page: http://ostermiller.org/convert_java_outputstream_inputstream.html describes how to create an InputStream from OutputStream: new ByteArrayInputStream(out.toByteArray()) Other alternatives are to use PipedStreams and new threads which is cumbersome. I do not like the idea of copying many megabytes to new in memory Bytes a...

hibernate: Is this mapping allowed?

@Entity public class A { @Column(name="Foos") @Basic private HashSet<Foo> fooList = new HashSet<Foo>(); } where class Foo is nothing special, just implements Serializable. Essentially I want to Serialize the whole HashSet to the database. This mapping works ok to persist, however when I try to load it I receive a ClassNotF...