java

Misplaced construct in homework

I do all my programming assignments in eclipse first before putting them in putty and submitting them to our teacher. In eclipse, I have this strange error in one of my methods. it says "Syntax error on token(s), misplaced construct(s)." public static int factorial(int iVal, boolean DEBUG) { int result; // Defensive programming i...

Java: Best way to display multiple buffered images in a horizontal orientation(e.g. film reel)

I have a doubly linked list that's storing a bufferedimage in each node. I can easily retrieve all the buffered images by creating an iterator and iterating through list. I want to display each node horizontally one after the other in some sort of a panel. This would be similar to a film reel where frames are linked one after the other. ...

Output issues in java program

Ok so this program is trying to display the middle digit of a 1-4 digit integer and if it has an even number of digits it should display that there is no middle digits, however I can't get it to output the answer properly, here is the code: public class digit { public static void main(String[] arg) { int MyInt1, MyInt2, MyIn...

Are there any provable real-world languages? (scala?)

I was taught about formal systems at university, but I was disappointed how they didn't seem to be used in the real word. I like the idea of being able to know that some code (object, function, whatever) works, not by testing, but by proof. I'm sure we're all familiar with the parallels that don't exist between physical engineering and...

Need Help In Writing To A File

Hi guys, i have the following class that writes to a file but is not working as i want. I call the write method in a while loop so that it writes a string to a new line. It only writes the last string. All the previous ones are not written except the last one. Here is the class: import java.io.FileReader; import java.io.FileWriter; im...

A4j buttons don't fire

I used richfaces in a JSF project. Now I'm trying the same with Seam. But I always get the same JavaScript error: Message: Object required Line: 2791 Code: 0 URI: http://localhost:8080/myapp/a4j/g/3_3_1.GA/org/ajax4jsf/framework.pack.js The s:button tag works <s:button id="eMail0" value="sButton" action="#{Mailer.sendMail}" /> Bo...

I'm trying to take an input using Scanner(System.in) but it's not letting me. Help!

So I'm trying to take an input from a user using Scanner(System.in) but when i try to type something into the console it won't let me. Can anyone help? Function.show(); Scanner input = new Scanner(System.in); if (input.equals("a")) { Function.outputFile(1, list); } input.close(); ...

Correct use of Hashtable with custom class

This piece of code generates unexpected output. Hashtable<Pair, Integer> results = new Hashtable<Pair, Integer>(); results.put(new Pair(0, 1), 2); System.out.println("[DBG] " + results.containsKey(new Pair(0, 1))); The output is [DBG] false. Why did Hashtable fail to register this element? Does it have something to do with the way I t...

Java XOM canonicalization - spurious characters

I am using XOM to canonicalize some XML. But there are some strange characters prepended to the output. The core of the code is as follows: String result; outputstream = new ObjectOutputStream(bytestream); Builder builder = new Builder(); Canonicalizer canonicalizer = new Canonicalizer(outputstream, Canonicalizer.EXCLUSIVE_XML_CANONICAL...

Jist/swans debug problem.

Hi StackOverFlowians, I am working on JiST/SWANS, Java-based discrete event simulator, in Eclipse. Moreover, in Vanet.info (http://vanet.info/node/14) extensions and improvements for JiST/SWANS have been developed. I used all the instructions(http://vanet.info/node/119) in Vanet info to prepare my simulation environment. There is n...

Velocity can't find resource with webApp.

Hello, I'm trying to create a webApp using GlashFish server and Velocity. But i get the following error: SEVERE: ResourceManager : unable to find resource 'temp.vm' in any resource loader. SEVERE: org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'temp.vm' velocity.proprieties: resource.loader=web...

Java service can't list files in directories

Hello everyone. I'm doing a Windows Service in Java, this service list the files in a directory and write the results in a file. My problem is that when i call Java.File.isDirectory() when the service is running it always results false (It works well when i run the service manually as any other program). Besides, if i try the following: ...

How to create a BKS (BouncyCastle) format Java Keystore that contains a client certificate chain

I'm writing an Android app that requires SSL client authentication. I know how to create a JKS keystore for a desktop Java application, but Android only supports the BKS format. Every way I've tried to create the keystore results in the following error: handling exception: javax.net.ssl.SSLHandshakeException: null cert chain So it looks...

Using internal sun classes with javac

Is there a way to disable restrictions of javac 1.6.0_22 that prevent me from using JRE internal classes like sun.awt.event.* ? I'm not looking for: an explanation why it is forbidden. suggestion to use different classes suggestion to use reflection suggestion to use ecj/eclipse I just want to know if it is possible or not, and if i...

Prevent Java from repainting the content of a JPanel while updating

I have a JPanel which contains a lot of child components. While updating\adding new components to the parent JPanel I'd like to prevent it from repainting, how can this achieved? ...

How to enable SSL debugging on the Android platform?

Is there something similar to setting -D javax.net.debug=ssl at the command line for Java desktop applications, but for the Android? I've tried setting it in code via System.setProperty("javax.net.debug", "ssl"); but that didn't work. If there isn't a way to enable this property, is there at least another way to debug the client side of...

Java: How to get the caller function name

To fix a test case I need to identify whether the function is called from a particular caller function. I can't afford to add a boolean parameter because it would break the interfaces defined. How to go about this? This is what I want to achieve. Here I can't change the parameters of operation() as it is an interface implementation. op...

Painting a custom JButton and a text line

Hi everyone! I'm designing an optimization system for public transport in a big city. So I have a map with some points on it, but don't care about it) All I need is: my own JButton, which looks like a color-filled circle and a small text tag near it. I got some problems while overriding the paintComponent() method.. the round button is p...

Minimum number of checks to validate a truth table

Hi all, I have a java program where I want to validate if any of 3 booleans is false. I want to figure out the smallest expression I can write to check against the permutations. if(!(needsWork && (needsApproval || isAdmin) )) I think this is enough to make sure that if any of the 3 booleans is false I want to stop processing. H...

Spring Roo does not generate CRUD

In Spring Roo I used this tutorial with my custom xsd to generate objects. After that I used command controller all ~.web, controller is generated but without CRUD functions. If I make manual objects in Roo controller with CRUD functions is generated. Any idea what is the problem? Schema file xsd is in my case important for REST data exc...