473,583 Members | 3,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Program won't compile

I am writing a program to store stuff to xml using the storeToXML method
but I can;t get it to compile here it is; any ideas?


import java.io.*;

import java.util.*;

public class XmlWrite {

public static void main(String args[]) throws Exception {

try {

Properties props = new Properties();

props.setProper ty("something" , "bla");

props.setProper ty("stuff", "brown and black");

props.setProper ty("morestuff" , "me");

props.setProper ty("enablepassw ord", "yes");

props.setProper ty("answer", "null");

String OperatingSystem = System.getPrope rty("user.home" ) +"\\";
FileOutputStrea m xmlwrite =
new FileOutputStrea m(OperatingSyst em + "config.xml ");

props.java.util .Properties.sto reToXML(xmlwrit e, "config");

xmlwrite.close( );
}

// if writing to the specified output stream results in an
IOException

catch (IOException e) {

//Print system error

System.err.prin tln("An Error Occured While Writing To The
File");
}

// if os is null.

catch (NullPointerExc eption e) {

//Print system error

System.err.prin tln("OS Value is Null");

}

}

}
Jul 17 '05 #1
2 1944
1. "props.java.uti l.Properties.st oreToXML(xmlwri te, "config")" does not make
any sense - not to the compiler, not to myself.

2. NullPointerExce ption should never be caught. Instead, your code should
check for null values and _prevent_ the NPE from ever happening.

3. If you ask for help in debugging code, provide the full list of the
compiler errors, as generated by the compiler. Just saying "is does not
compile" won't get you any help.

"Gary Redmond" <gr@iol.ie> wrote in message
news:KH******** ***********@new s.indigo.ie...
I am writing a program to store stuff to xml using the storeToXML method
but I can;t get it to compile here it is; any ideas?


import java.io.*;

import java.util.*;

public class XmlWrite {

public static void main(String args[]) throws Exception {

try {

Properties props = new Properties();

props.setProper ty("something" , "bla");

props.setProper ty("stuff", "brown and black");

props.setProper ty("morestuff" , "me");

props.setProper ty("enablepassw ord", "yes");

props.setProper ty("answer", "null");

String OperatingSystem = System.getPrope rty("user.home" ) +"\\";

FileOutputStrea m xmlwrite =
new FileOutputStrea m(OperatingSyst em + "config.xml ");

props.java.util .Properties.sto reToXML(xmlwrit e, "config");

xmlwrite.close( );
}

// if writing to the specified output stream results in an
IOException

catch (IOException e) {

//Print system error

System.err.prin tln("An Error Occured While Writing To The
File");
}

// if os is null.

catch (NullPointerExc eption e) {

//Print system error

System.err.prin tln("OS Value is Null");

}

}

}

Jul 17 '05 #2
storeToXML is Java 5.0. You have to compile it with -source 1.5 (I think).
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5716
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning is to improve, but not to prove.
6
2780
by: tigrfire | last post by:
I've been working on a program to try and play a game of Craps, based on a version I found elsewhere - I didn't code the original, but I added a few things such as a balance and wager system. I'm having trouble doing it all without using global variables though, so I have another post in this group about local variable usage and how to pass...
2
1120
by: Gabriel Hernandez | last post by:
Well I am just getting started with C++ and I am having a problem. I created a very simple program and when I try to compile it I receive this message Cannot compile the file 'C:\Program Files\Microsoft Visual Studio\MyProjects\Gabriel\Text1.txt'; no compile tool is associated with the file extension. Any help will be greatly appreciated ...
16
4806
by: Martin Joergensen | last post by:
Hi, I wanted to try something which I think is a very good exercise... I read in data from the keyboard and store them in a structure. There's a pointer called "data_pointer" which I use to keep track on the structures... But it's a bit confusing - my program won't compile and I don't know what to do about the warnings/error messages. ...
6
1381
by: Howard Gardner | last post by:
/* As it sits, this program won't compile for me. It will compile using either of the versions of tpt that I've commented out. Which versions SHOULD compile? I think that the code is interesting because I think that it is on the path to building a useful non-intrusive type introspection facility. The version that uses "has" indicates the...
0
1720
by: Tom | last post by:
I have a .net v2 asp.net problem. I develop on my workstation and deploy to a production server. I use compile on demand, so no pre-compile is done. When I deploy, I first must move in my new or changed pages. Then I must restart IIS. After that, everything is good, and I run for weeks without problems. If something should cause a compile...
10
1392
by: Ron | last post by:
I've got this simple program that will not build or run, any idea what I am doing wrong? Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim c As Double = CDbl(txtOrderCost.Text) Dim r As Integer = CInt(txtMonthlyDemand.Text) Dim p As Double = CDbl(txtPartCost.Text)...
21
4254
by: AsheeG87 | last post by:
Hey Everyone~ I'm still a C++ Rookie so please bear with me on this. I'm doing a temperature conversion program with prototype functions. Basicly, I was wondering if some of you would take a look at my code and critique it for me. I'm mostly concerned with how prototype functions work and if I designed them correctly in my code. Your...
4
4051
by: Billy | last post by:
Hi! I'm using: -Compiler: Borland Command Line C++ Compiler 5.5.1 -Code Editor: SciTE 1.75 Anybody know how we can in Scite with command Tools|Go (F5) compile and run my c or cpp program at the same time? So I won't first compile and then run, but all in one step.
0
7827
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8184
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8195
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.