Solved

Changing a settings file in a Java program

Posted on 2002-04-26
6
179 Views
Last Modified: 2010-03-31
Hi,
When I install a Java application, it requires a connection to a database. The flaw in this program is that it has a default database name (DSN) to which it tries to connect. Unless you happen to have that data source on your machine, it will fail. When installing this application, it never gives you the option to edit the DSN name. Can anyone suggest how I might change this? I am not a java programmer, so be gentle!. I suppose i need to change one of the source files for this.
thanks for any assistance
Mike
0
Comment
Question by:mikeandbee
6 Comments
 
LVL 7

Expert Comment

by:yoren
ID: 6971895
I would first check the documentation of this application. If this application ignores all sensibility and does not give you the option to change the DSN, read on.

You'll have to change one of two things, depending on the application. It might be reading the DSN from a properties (settings) file, or it may be embedded in the application.

The easiest way to find the problem is to unpack the source files and use an editor that lets you search for the DSN string in multiple files. If you find it in a properties file, you won't have to recompile. If you find it in the source, you'll have to run "javac <file>" for the changed file.

Yuval
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6972592
Two options:

1. Pass the DSN as a paramater on the program as a command line:

java -Ddsn=xyz mypackage.MyClass

2. Store the DSN in a properties files, and have your program read it from there.
0
 

Author Comment

by:mikeandbee
ID: 6977791
I can change the DSN in the properties file AFTER it has been installed, but what I want is for the program to give me the option to add/find a DSN on my system, and not hardcode the DSN into the settings file. Is it possible tochange this with little knowledge of Java? Do i need a Java programming environment to do this (which i don't have)?

thanks
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 92

Expert Comment

by:objects
ID: 6978707
> Is it possible tochange this with little knowledge of Java?

Define little.
Sounds like this would require a code change.

> Do i need a Java programming environment
to do this (which i don't have)?

Yes.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7992289
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: objects
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8048111
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
json example 39 111
mapShare challenge 13 68
java  and programming certification ? 4 64
recursion example 16 68
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now