Java SetProperty Not Working
Apr 17, 2015
I have a file called config.dedserver and on a JButton click I am editing the values in it using setProperty but it didn't work. It removed everything from the entire file and then added the properties.
This is my code:
String newGems = gem.getText();
String newGold = gold.getText();
String newElixir = elixir.getText();
String newDE = de.getText();
try {
Properties props = new Properties();
props.setProperty("startingGems", newGems);
[Code] ....
And this is what the original file is:
Quote
# Main configuration file for DEDServer
# Starting resource values
startingGold=1000000
startingElixir=1000000
startingDarkElixir=1000000
startingGems=1077
# Saving method. Valid values are:
# -none: database disabled
# -h2: use h2 database (default)
saveMethod=h2
# Save interval (milliseconds)
saveInterval=60000
View Replies
ADVERTISEMENT
May 20, 2015
I am trying to understand the package and import functions.
The path to access the file " library.book" is
C:UsersKameshDesktopJava SessionJAVAOCA7ooklibrary
and i can see 3 txt files
Book.class
Book.ctxt
Book.java
while compiling i am getting <identifier>expected error.
Here is the code :
package library;
public class Book {
public String isbn;
public void printBook() {}
}
package building;
[Code] .....
The error i get is <identifier>expected.
View Replies
View Related
Feb 22, 2013
how to create pdf file while working in java.
View Replies
View Related
Dec 10, 2014
I have been working on getting the merge sort working, I have a complteted code but am not getting the right results... Here is my code and the results are "876323149" ...
public class MergeSort
{
private static int[] local; // for use in copying
private static int[] a;
public static void main(String[] args) {
int[] test = {2,3,1,4,7,8,6,3,9};
[Code] ....
View Replies
View Related
Sep 5, 2014
I had a game written in a 500x400 window using JFrame and a threaded JPanel. It used KeyListener to detect user input and worked just fine, problem was it was very click dependent and therefore I wanted to put it into fullscreen mode so I would no longer come across the problem of clicking outside the window and being taken out of the game. But when I ported the game to Full Screen Exclusive Mode the KeyListener no longer seems to be working and I have no clue why. I tried using KeyBindings as well, that code didn't work and is left commented out in the FSEM code.Here is my code for the windowed application:
import java.awt.Container;
import javax.swing.*;
public class Main extends JFrame{
private GamePanel panel;
public Main(){
panel = new GamePanel();
[code]....
View Replies
View Related
Aug 21, 2014
I am trying to use the JList to display a list of students. Now, each student has a first name, last name and course taken. each courses taken by the student has its' own name, level and idNumber. For now, I am just trying to create my own custom JList model for the students. I have the custom model as well as the button event calling it. Unfortunately, when I click the button to display the student info added, the component is NOT fired up!..
I am not sure what I have done wrong regarding creating the component because I can display the information on the console and the list contains everything I have added but just to display it on the component is NOT working. I have broken the codes into sub classes, you can add the classes to the same package or create sub packages to insert individual classes.
The student class
public class Student {
private String studentName;
private String studentID ;
public String getStudentName(){
return studentName;
[Code] ....
View Replies
View Related
Apr 18, 2014
I am currently writing two java classes (client and server). The client takes an input number form keyboard and sends it to the server. The server then multiplies this number by two and sends it back to the client. The numbers should also be printed to screen along the way, for example if I input the number 3 I should get
"From Client: 3" "From Server: 6"
They should continuously do this unless a negative number is received by the client, say for example the number -3 is sent to the server and it returns -6.
The code I have for the two classes so far is:
import java.io.*;
import java.net.*;
import java.nio.ByteBuffer;
import java.util.Scanner;
class Client {
public static void main(String args[]) throws Exception {
DatagramSocket clientSocket = new DatagramSocket();
[Code] .....
Currently, when I run the program all I get is an output of the number first entered. I am aware it requires a loop but I don't know where and what the condition should be.
Also if I wanted to adapt this so that it would take the integer from client and subtract two at the server and return to client who sends back to server to keep subtracting two unless it reaches a negative number at which point the client will terminate the program - how might I do this.
I do realise there needs to be a while loop in the above code, but I wanted to test it sent the number from client to server and its not doing it. All I get is a print screen of 'enter number' and then the number I enter.
View Replies
View Related
Aug 6, 2014
I am currently working on a Java project, below are my attempts at coding so far:
public class MyZoo
{
// zoo identifier
private String zooId;
// a number used in generating a unique identifier for the next animal to be added to the zoo
private int nextAnimalIdNumber;
// zstorage for the Animal objects
private TreeMap<String, Animal> animals;
[Code] ....
I currently cannot get the printAllAnimals() method to work as it should.
When executing the method printAllAnimals(), it does not do anything, when it is supposed to use the Collection object c, so that animals stored in the zoo can easily be checked.
View Replies
View Related
Jul 7, 2014
I have written my whole java code in netbeans IDE and create database in MYSQL work bench and connected java Gui with this DBMS through requried driver.when i run this program from Netbeans IDE , my program successfully access the data from DBMS. But when i created this java gui exe file its not working and not accessing data from DBMS, and each times gives exception "Driver not found ".if there is no driver loaded in this program how this file is working when i run this file from netbeans .
View Replies
View Related
May 5, 2015
***** start code ***
public class AddArray {
public static void main(String[] args) {
int sum = 0;
sum = addArray(myarray);
System.out.println(" hello");
System.out.println("This program will create an array then pass the array to an method to be totaled");
int myarray[] = new int [6];
[Code] ....
View Replies
View Related
Oct 10, 2014
Code structure :
Server : Java Servlet
Client : Simple JSP
Communication : Server Sent Events every 1 second
Here is the problem.
My code needed the server to send updates every one second to the client as stated above. Hence, I added a while loop with a sleep of 1000 milliseconds in the servlet code as shown below. The following strange behavior is observed:
- While the server is sending updates to the client, and the client window closes by mistake, the server does not stop sending updates It continues sending the data.
- When the client is re-opened, it sends data much faster (almost double). For example, the server sends 60 seconds worth of updates (60 updates) in just 25-30 seconds. The server sends faster updates not only for this round of updates, but also for any subsequent updates.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
PrintWriter writer = null;
try{
[Code]......
This server behavior is much unexpected. Am I writing the server side code wrong? I have looked around a lot and only found while loop method for modifying the server update interval. Is there any other method which I am missing?
View Replies
View Related
Mar 17, 2015
I have installed the lastest version of GlassFish and I wanna create new datapool using MySQL.
But when I create it and then I ping it, it shows me this error:
Ping Connection Pool failed for Testing. Connection could not be allocated because: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: java.net.ConnectException: Connection refused: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection refused: connect at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
[Code] ....
View Replies
View Related
Apr 10, 2014
I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,
1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.
2) The problem may be to display the JDesktopPane or JInternalFrame.
My working Server Code extends withe JFrame..Java Code:
package remoteserver;
import java.awt.BorderLayout;
import java.awt.Container;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JApplet;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
[code]....
View Replies
View Related
Feb 5, 2014
I've been working quite a bit with a login system the past couple of months and I now have a version that I would like to try "for real" by extracting it as a runnable .jar or .exe file. I've looked at a couple of guides that told me how to do this properly, but even after following every step precisely it didn't work.
One of the guides I tried: 3 Ways to Create an Executable File from Eclipse - wikiHow
Double clicking the file or selecting it and pressing enter does nothing, the computer loads for a second and then nothing happens. I don't receive any visible errors when extracting the program, either.
However, when running the file from the command prompt I do receive an odd error:
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:UsersUserName>java -jar Login.jar
Exception in thread "main" java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at LoginSystem.Data.updateData(Data.java:347)
at LoginSystem.Data.<init>(Data.java:309)
at LoginSystem.MainFrame.<init>(MainFrame.java:42)
at LoginSystem.MainFrame.main(MainFrame.java:457)
C:UsersUserName>
I must say I don't quite understand the error, it seems to be unable to load an image which is odd considering the program works fine without any errors at all in Eclipse.
View Replies
View Related
Oct 6, 2014
I made an Analog Clock and its working but when a remove the filloval (Background) the seconds hand keep repeating itself..here is the code
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;
[code]....
View Replies
View Related
Feb 2, 2015
I am trying to sum up the elements of an array. When I test my code the sum is always off by one. For example if I input: 20, 40,30 it gives me 89 instead of 90.
This is what I have so far:
public static void main(String[args]){
int size = kbd.nextInt();
int [] myArray = new int [size]
//user inputs the elements of array
[Code]....
View Replies
View Related
Mar 16, 2014
I have a java program which would display a message dialog box. The problem is it would stopped working before even displaying the message dialog box. This is my code.
import javax.swing.JOptionPane;
public class HelloDialog {
public static void main(String [] args) {
JOptionPane.showMessageDialog(null, "Hello World!");
}
}
There is a pop-up window which would say "Java(TM) Platform SE binary has stopped working." I am using textpad. What should I do with this?
View Replies
View Related
Aug 31, 2014
I have written a java applet. Few months before It was working all fine but my client has some other requirements now and I have to edit it. I am getting two problems:
1. I could not execute it on my local computer as it always gives "your security settings have blocked a local application from running". I have edited the settings from Control Panel but it is then started giving permission error on including permission in manifest file it started giving trusted library error and still it is not resolved.
2. Can I know how to work with third party library with applets. I have imported the library and uses its few classes but when I tried to load applet it always give no class definition found error. I have some ways mentioned online like use comma separated names for all the jars but no luck so far.
View Replies
View Related
Nov 19, 2014
I am getting the following message when trying to print a JTable.
"Java(TM) platform SE binary has stopped working"
Here is the code:
try {
MessageFormat headerFormat = new MessageFormat("Page {0}");
MessageFormat footerFormat = new MessageFormat("- {0} -");
table.print(JTable.PrintMode.FIT_WIDTH, headerFormat, footerFormat);
} catch (java.awt.print.PrinterException pe) {
System.err.println("Error printing: " + pe.getMessage());
}
View Replies
View Related
Aug 29, 2014
Why in my program keys are not working, what I forgot to write?
import javax.swing.JFrame;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Stickman");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(450, 490);
[code]....
View Replies
View Related
Mar 5, 2014
I got my code into a jar, but when I run it I get his message:I just used Eclipse to make my jar and I thought I did it right but I guess not.
View Replies
View Related
Apr 24, 2014
I wrote a piece of code:
for(int i = 0; i < x; i++){
System.out.println("Enter students full name:");
sName[i] = result.fullName(sc.nextLine());
sExam[i] = result.examName("VB");
System.out.println("Enter students exam score:");
int scor = sc.nextInt();
sScore[i] = result.examScore(scor);
sGrade[i] = result.examGrade(scor);
}
When i run it i get:
Enter number of students:
1
Enter students full name:
Enter students exam score:
The problem is, i cant enter "full name", program is just jumping to the next step "exam score".
View Replies
View Related
Oct 9, 2014
I am working on a fairly simple program where I have a colour change three times using the red green blue spectrum. The problem is that I keep getting a result of zero no matter what I do.
import java.awt.*;
class RectangleMain
{
public static void main (String[] args) {
ColouredRectangle blocky = new ColouredRectangle(50, 100, 20, 40, Color.red);
System.out.println(blocky.getColour());
blocky.mixColour(Color.blue);
[code]...
View Replies
View Related
May 31, 2014
I'm programming a game, but the keyListener doesn't work. Here is the source code:
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class InputHandler implements KeyListener{
public InputHandler(Game game) {
game.addKeyListener(this);
[code]....
My Question is: Why will it not say "up", if I press "w"?
View Replies
View Related
May 5, 2014
I'm having a problem where an if statement isn't working. In the Person class boolean olderThan ignores my if statement so it always returns false and I just don't get why that's happening.
import java.util.Calendar;
public class Person {
private String name;
private MyDate birthday;
public Person(String name, int pp, int kk, int vv) {
this.name = name;
[code].....
View Replies
View Related
Feb 25, 2015
I have added a Simple Jar file in Eclipse Proect->BuildPath->jar file but class Inside that are not showing in My project this is my Project Structure and I have all ready checked in Order and Export..But jar file is not working.
View Replies
View Related