about the game of homework craps

this is the first time for my asking a question here. im new to java and i hava a problem with the loop in this code i dont know where to break the loop. thank you for helping me :) this image is from the book regarding this question import java.util

no target devices found android studio 2.1.1

i'm using android studio 2.1.1 in ubuntu 14.04.Now my question is,i want to run the program through my phone without emulator. so i chose the target as usb device but whenever i run this,below mentioned error is rasing. Error running app : No target

Use the global installation graded with Buildship

I want to create a Gradle project in Eclipse using Buildship. When I create it, the IDE tries to download Gradle 2.9 from somewhere. But I have a system-wide install of Gradle 2.12 (installed by pacman). How can I convince Buildship to use my local G

Hibernate can not save an object

I am doing the introductory tutorial on Hibernate from PluralSight. For my database, I am using MYSQL. In my main method, I am creating an object and I am trying to save it. However, I get the following error: Exception in thread "main" org.hibe

Query on Java discussions

I was reading Multithreading from The Complete Reference and then I was struck at this code,I am unable to understand the output of this code.Can somebody help me with this? class NewThread implements Runnable { Thread t; NewThread() { t = new Thread

Java string to double

I recently began to program in Java, and i ran into a little problem: I already made a String to Double line, but it doesn't seems to work proberly. As you see, the string I want to convert into a Double is one of following: USD, GPB and EURO. I know

Bitwise left offset behavior

Today I was learning about the left shift bit operator (<<). As I understand it the left shift bit operator moves bits to the left as specified. And also I know multiply by 2 for shifting. But I am confused, like what exactly is the meaning of "

@Transactional does not work at the method level

I have a question about Spring 3.2.3 @Transactional annotation. My Service class looks like this: @Service @Transactional class InventoryDisclosureBO { @Autowired InventoryDisclosureDAO inventoryDisclosureDAO; private static final Logger log = Logger

how to read a file line by line and add a string each line?

I want to open a file and then read it line by line. In some lines I want to append a string to exactly this line. Is this possible? I have a code for opening the file and reading it like the following: File file = new File("MyFile.txt"); Buffer

How to make the value of the permanent guava cache

Is it possible, using Google Guava's Cache, to keep my cached value in the cache permanently? Below is how I build my cache: cache = CacheBuilder.newBuilder() .expireAfterWrite(60, TimeUnit.MINUTES) .maximumSize(100) .build(....); I want my cache to

No Persistence Provider Error for OSGI Bug with JPA Support

I have created small OSGI buldle project with the JPA2.0 support to persist the Student(Entity class) Object. I would be able to start this service successfully. I have created another client bundle project to access this service. When I try to start

HttpServletResponse # sendError How to change ContentType

I'm now creating a simple Servlet to answer a form submition. This servlet receive POST request and should response Application/JSON datas. This is working well. I want now to add errors managment to my servlet: If the servlet receive bad request par

The JAR file does not play sound while Eclipse

I have a project that I want to export as a jar file. The software is supposed to play a sound at a certain point in time. However, the problem is that the JAR file does not play the sound file when that point in time is reached. When I run the same

To calculate the total elapsed time using threads in Java

I have this java code using Threads to calculate the time elapsed once the start button is hit till the stop button is not hit. I want to do this using Threads only import javax.swing.*; import java.awt.event.*; // This will count the elapsed time be

JAVA: FileInputStream and FileOutputStream

I have this strange thing with input and output streams, whitch I just can't understand. I use inputstream to read properties file from resources like this: Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream( "/resour

java hibernate ignore the 'id' insert on the insert

I have designed a table (in postgres) where 'id' column is autoincremented via its SEQUENCE entity. But when I began use hibernate I met the problem .... due creating the insert statement, it use the follow statement INSERT INTO mytable (id, name) VA

Is there a tool to represent the XML hierarchy?

I am currently working on a spring application, which contains a lot of xml files. To grab the hierarchy of xml, I use to draw like this on paper: main.xml ------>child1.xml---->child2.xml ------>chil12.xml ..... Now my question is, Is there any

java.lang.VerifyError: Wait for a stackmap frame

Is there a way to load a custom HttpServlet to GAE? I uploaded a project that included an HttpServlet in the .server package and added it to the web.xml... <servlet> <servlet-name>testServlet</servlet-name> <servlet-class>gwtone.se

Legacy Java Update

I have a Java servlet website, but does not use any frameworks like Spring or even Struts! It does have hibernate in it which it uses along side regular sql. It also has no unit tests. It uses cvs and ant. The server can only run Java 1.4 in the JSP'

double arithmetic and equality in Java

Here's an oddity (to me, at least). This routine prints true: double x = 11.0; double y = 10.0; if (x-y == 1.0) { // print true } else { // print false } But this routine prints false: double x = 1.1; double y = 1.0; if (x-y == 0.1) { // print true }

Format an integer using the Java string format

I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros? For example: 1 would become 001 2 would become 002 ... 11 would become 011 12 would become 012 ... 526 would remain as 526 ...etc At the mom

How to convert an int to a string?

I have an int variable and when I am setting this variable as an Android TextView's text it's throwing an error, maybe because it's an Int. I have checked but couldn't find a toString function for the int. So how can I do that? int sdRate=5; //text_R