My code has three property file and I want to give input through maven. How to give input for three files in VM agrument.
How to pass the -D System properties while testing on Eclipse?
I am following this link. But this link shows only for one property file. I want to give for three property file at once. Please suggest how to do it
You can use the mentioned approach multiple times like :
-Dkey=value -Dkey2=value2 -Dkey3=value3
Related
I m trying to write an eclipse plugin which is suppose to render xml file some different manner. What actually I want is to replace the name of the file displayed in the project explorer with one of its element without originally change the file name. for example I have a file named 1234.xml with content
<name> dinesh </dinesh>
<college> NITT </college>
So I want to change the name of 1234.xml to dinesh.xml in the project explorer.
Can anybody tell me what are the possible ways I can achieve this.
I am new to eclipse plugin development. So please provide me as much information as possible.
There is no automatic way (I mean refactor) for this, so you must manually do it:
Change name of file 1234.xml to dinesh.xml
Search in your project all references to 1234.xml with CTRL + H / file search and appropiate patterns:
Change all references found of 1234.xml to dinesh.xml
If some issue appears search for 1234 in all the files to check if file was references only by name
Well I find the answer of what I wanted to do...
I have extended decorator extension point of eclipse to provide custom label provider for the desired files ...
One more thing to access the xml attribute use regex instead of xml parsing . It will make things bit faster than xml parsing ...
Thanks
I have the following doubt related a Java properties file.
Into a project I have a config.properties file that contains something like these lines:
Mailer=C:/Projects/MY-PROJECT/src/config/mailer.properties
Upload=C:/Projects/MY-PROJECT/src/config/upload.xml
Soap=C:/Projects/MY-PROJECT/src/config/soap.xml
Libretto=C:/Projects/MY-PROJECT/src/config/libretto.properties
So what is the exact meaning of these lines into a properties file? I think that is how I am including the content of 2 .properties file (mailer.properties and libretto.properties) and of 2 .xml file (upload.xml and soap.xml)
Is it right or is it a wrong interpretation?
Tnx
Properties is a very simple format and does not support any kind of import. Such logic (if required) must be implemented at application level.
This means that exact meaning of properties file snippet that you posted can be discovered by examining code of your application. I suppose that this file contains references to other files, so somewhere in your application exists code that parses this file, extracts paths to other files and reads them too.
How to make program i made by java know certain file types and make windows open that certain extension by it ?
How i can put a picture to put it for that extension when it's the default program ?
As example when i setup a FOX-IT reader it terns all PDFs files into FOX-IT reader & the FOX-IT picture putted on the PDFs files also ?
if there is a class that access a certain file in windows ?
You're talking about changing Windows settings, rather than anything to do with your program itself.
This is a question about Windows, not about Java.
Normally, you would hold shift while right-clicking on the file, select "Open With" and then pick the program that you want to use to open the file type.
However, since you are talking about a Java program, you probably don't have an executable to run.
In this case, you will need to create the association in the registry yourself.
As always when dealing with the registry, don't change things there unless you know what you are doing, as you can break your system.
Under HKEY_CLASSES_ROOT, create a new key for your file type. I'll use the ".abc" extension for this example, so first create a new key with the name ".abc".
Set the (Default) value of your key to "abcfile"
Now, create another key (again under HKEY_CLASSES_ROOT) named "abcfile". The (Default) value here is the name you will see in the Type column.
Add the following tree of keys underneath abcfile:
abcfile
| shell
+-| open
--+--| command
In the (Default) value of "command", put in the command that you wish to run when opening the file. Use quotes for paths with spaces, and "%1" in place of the filename.
For example:
"C:\Program Files\Java\jre7\bin\java.exe" -jar "C:\path\to\jar\MyJar.jar" "%1"
To change the icon, you will need to make another key under "abcfile" named "DefaultIcon".
Set the (Default) value of this key to the path to your icon file.
To open an application associated with the file extension you'll need to use the java.awt.Desktop class. Oracle has a tutorial with sample code.
Getting the icon for an application is more difficult. Your best course of action is to include standard icons as resources in your application; that should cover most scenarios.
I have a .property file in my Java project. In that property file have more than 20 values. Now I want to parse that property file and change the specific property value at run time(that is when run the install file). I have used following code
Section
${ConfigWrite} "C:resource\conf.properties" SET WEBSERVICE.URL=http://localhost:8080 $R0
;$R0=CHANGED
SectionEnd
After running exe file ,the property added in property file like this
SETSERVER.URL=http://localhost:8080
I don't know why the SET words comes before this variable?
My requirements:
I need to give value for SERVER.URL property at run time (while installing the exe file)?
I need to replace the value of SERVER.URL property.but Using above added one more new property in that file.
I have used NSIS plugin in Eclipse on Windows platform.
You are missing some quotes when calling the macro, also there is no need to specify SET (in the example from help, SET is actually part of a command in a DOS batch file), and I guess that it is better to add a backslash to the path after the disk drive.
The doc states that the syntax is:
${ConfigWrite} "[File]" "[Entry]" "[Value]" $var
Therefore your call must be:
${ConfigWrite} "C:\resource\conf.properties" "WEBSERVICE.URL" "=http://localhost:8080" $0
Note how the parameters are splitted between the parameter name WEBSERVICE.URL and the value =http://localhost:8080 (note the equal sign at the beginning).
You can make the directories dynamic too:
${ConfigWrite} "$INSTDIR\resource\conf.properties" "WEBSERVICE.URL" "=http://localhost:8080" $0
Anyone plz let us know what to do when we have some configuration file which is basically xml.I want to for example give the path to save the image(for my java program) in a folder from some config file (xml in my case).In that case where should the config file be kept.Rt now every thing is converted to jar file when i create a java standalone package.But i want to give some setting from xml file.What to do in that case.How is it possible.This article only provides to create a single jar file for java project but talks nothing about the configuration settings that u can provide from some external source.
Regards
Sagar
I'm not sure I fully understand your question, but if it is where to put the XML file with configuration information, you can place your xml file in the same directory as your jar file, and then pass the XML file name and path into the Jar on the command line when calling the Jar. If you're running it in Windows, this is often done using a shortcut. Then you can get the full path string for the Jar from the main method's String[] arg array that accepts the command parameters.
Sagar,
The fact your java program is a standalone package (.jar file) has no bearing on where your configuration file is stored. Your java package is a program and that program can read any file from the file system that it so desires; it does not have to be part of the code inside the IDE i.e. you don't have to write it when you write the program. What you do need is some way, when you start the program, to find and read said configuration file.
Depending on how you expect the program to be configured, you might put that file in a number of locations. For example, /etc/yourimageprogram/config.xml or c:\program files\yourimageprogram\config.xml or perhaps c:\users\Sagar\Application Settings\yourimageprogram\config.xml. Which you choose of those options really depends on what the use case is and that I can't help with.
However, there are some main points to reading any file:
Does it exist?
Are we allowed to open it for reading?
Are we allowed to open it for writing? Might want to know if we want to update the config?
In Java, typically, you would test this with:
File configfile = new File("C:\test.xml");
if ( configfile.exists() && configfile.canRead() )
{
// read the file
}
else
{
// decide what to do if no config exists.
// might be first run of app.
}
The next stage is to parse the file. There are a number of parsers available for XML including sax and org.w3c.dom. What you need to do is to use these to extract the information you require and store that in a class. Probably a singleton class as you're unlikely to have multiple configuration instances per instance of the program.
I suggest you read about XML Parsers and File Handling under Java. Also look at the File object. See all your options for file io in java. These should give you some indication of how to proceed.