Listing System Properties With A Linebreak
Apr 6, 2014
I am quite new to java and trying to print all the system properties with the following
code:System.out.println(System.getProperties());
This prints all the properties as expected but I am wanting to put each property on a new line and am struggling a bit. Obviously I will need some sort of for loop etc but im just not sure how to do it. Is it something along the lines of:
for (int i = 0; i < System.getProperties().size(); i++){
What my understanding of what the above is doing is checking how many properties there are an looping round for each property that exists, so all I need to do is get the property 1 at a time however I am not sure where to get the property value to input into the System.getProperty(); method.
View Replies
ADVERTISEMENT
Oct 28, 2014
I am maintaining an existing Java product (which has a HUGE code-base). I discovered that it is setting (and getting) two of its internal passwords as Java system properties, at no less than 4-5 different places (methods). Now, the problem is, the passwords are being stored as plain text in the Java system properties, and so, the same is visible to external entities, as the application is not using any Java Security Manager. For example, if the application (process) is running on port number 1234, we can run the Java command:
jinfo -sysprops 1234
to view both the passwords as values of the corresponding Java system properties. I wish to ask if there is any remedy to this without changing the existing code-base too much? The desired effect would be to "hide" the two Java system properties (denoting the two passwords) from all external entities.
It may be noted that introducing a Java Security Manager into the application may not be a solution, as if we revoke read permissions from the said two Java system properties using the Java Security Manager, the application codes which read those properties would crash. Same is applicable for storing the passwords in encrypted form, as that would crash all codes within the application which are expecting to read the passwords in clear text form.
To give a bit more context, the said two passwords we are storing as Java system properties are actually passwords to access two key-stores, and Tomcat requires that we store the said two passwords in plain-text format. Any workarounds, such that only Tomcat will be able to see the two passwords as-is, while they will be invisible to all other external entities?
Or, is there any way to place the said passwords in other in-memory locations (like static variables) which only Tomcat can (be made to) read instead of placing them as system properties which is exposed to anyone?
View Replies
View Related
Mar 4, 2014
I'm scanning my text and I want to add them into array list, but it is not easy. I want each word store from arrayList of a to z which is arrayList size is 26. Example:
arrayList a store string array of: an, and, apple, ...
arrayList b store string array of: be, become, became.....
.
arrayList z store string array of: zero, zone...
In my class, I create:
private static ArrayList<String[]> words = new ArrayList<String[]>(26); // to store all words
In main, I do while loop to get each words and store in words array,
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;
public class BinaryTree {
[code]...
View Replies
View Related
Apr 22, 2014
I'm making a class in Android that takes a photo, list a photos in Listview, and then sends them all to server. I'm stuck on listing them. How to send them all to server.
Here is my code :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_upload);
Button picBtn = (Button) findViewById(R.id.buttonPhoto);
setBtnListenerOrDisable(picBtn, mTakePiconclickListener,
MediaStore.ACTION_IMAGE_CAPTURE);
[Code] ....
Executing this code i can take a first photo and place it into listview. But on second photo listing it crashes..
View Replies
View Related
May 25, 2015
Need to know how i can store a value in File which is in Properties?
Here I am placing my Properties code :
ReportHTML C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_HTML_DUMP/
ReportEXCEL C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP/
My Java File :
File destHtmlFolder = new File("C:/bea/user_projects/domains/OICDomain/DOC_SERVER/REPORT_HTML_DUMP");
File srcExcelFolder = new File("C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP");
View Replies
View Related
Mar 13, 2014
I have an XML doc that looks like this:
Java Code:
<?xml version="1.0" encoding="UTF-8"?>
<model>
<id>_1</id>
<nodes>
<id>_2</id>
<stencil>TASK</stencil>
</nodes>
<nodes>
<id>_3</id>
<stencil>TASK</stencil>
</nodes>
</model> mh_sh_highlight_all('java');
I have to create another xml doc with the properties of nodes from the first doc. For the new doc I have to create a parent node called "definitions". Instead of the "model" node in the first doc I have to create a "process" node in the new doc that has an attribute "id" which value is the same as the content of the "id" child node of model. For each "nodes" node in the first doc if their "stencil" child node content equals "TASK" I create a "task" node in the new xml doc.
Java Code: <?xml version="1.0" encoding="UTF-8"?>
<definitions>
<process id="_1">
<task id="_2">
</task>
<task id="_3">
</task>
</process>
</definitions> mh_sh_highlight_all('java');
[code]....
I just wanted to know if this is the correct way to define the respective classes.any way to create and fill the nodes for the new doc using this classes? I am used with DOM parser and I know how to create nodes and fill attribute values, but I have always done this job in a single class, not using different classes for the elements.
View Replies
View Related
Dec 18, 2014
I currently have some code using a JFrame. I am trying to access the items in a JList to save them in a TXT file. For this, I am using a "for" loop. The problem is, is that when I try to access the list items, I can't access them. The way I am trying to access the items is by using:
Java Code: listRight.getModel().getSize(); mh_sh_highlight_all('java');
BUT, I can't seem to get this to work. I tried to place this for loop everywhere and I can't access it. I tried accessing it under "public class Window", "private JFrame frmPcPartBuilder", "public static void main(String[] args)", "public void Initialize()" and I can't seem to access the JList. I basically have a save button that saves the list to a text file and the code I am trying to write is called by this button.
Java Code: package com.cooksys.assessment;
import java.awt.EventQueue;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JButton;
[code]....
View Replies
View Related
Oct 29, 2014
A triangle is defined by the x- and y- coordinates of its three corner points. Compute the following the following properties of a given triangle: the lengths of all sides, the angles at all corners, the perimeter and the area. The program must prompt a user for the point coordinates. I have created a class Triangle and a class TriangleSimulator, I am stuck and can't figure out why my program won't run correctly.
import java.util.Scanner;
public class Triangle {
Scanner in = new Scanner(System.in);
private int x1;
private int x2;
private int x3;
[Code] ....
View Replies
View Related
Jul 21, 2014
I am using JPF controllers. Already, i am loading a properties file in the controller
(using annotations @Jpf.Controller(messageBundles = { @Jpf.Message Bundle(bundlePath = "validation.validator.Messages") },).
I have a problem. Depending on one of the request variables, i need to load different properties files. All these property files have same keys, but with different messages. I need to take the user to different sites(though internally, the backend logic remains same...Look and feel of the front end along with messages to be shown change to make the users feel they are being directed to a different site).
I am thinking of loading the properties file from the JSP when the user logs in first time from login page so that these properties are available until the session expires & not read the properties file in Controller.
View Replies
View Related
May 29, 2014
I'm developing an Applet that print a bar code using Jpos API. I need some jars and two configuration file. I've added jars to the classpath and configuration files in src directory. In Eclipse everything works fine.
DefaultProperties prop = new DefaultProperties();
prop.loadJposProperties();
SimpleXmlRegPopulator xmlReg = new SimpleXmlRegPopulator();
xmlReg.load(wincor.jpos17.THxxx.xml");
Everything works fine in Eclispe but I can't find property files when i call the applet from a web page. So I've checked the JavaPos sources and I've paste the loadJposProperties() and xmlReg.load("wincor.jpos17.THxxx.xml") content in my source code:
InputStream isD = prop.getClass().getClassLoader().getResourceAsStream(prop.JPOS_PROPERTIES_FILENAME); // (1) content of loadProperties
if (isD != null){
System.out.println("jpos/res/jpos.properties found");
[Code] ...
The same method is used to found wincor.jpos17.THxxx.xml. So when I call applet form the browser I get INPUT STREAM FROM PROPERTIES OK!! from (1) and jpos/res/jpos.properties not found from (2).
So getClass().getClassLoader().getResourceAsStream works if i write it directly in my code, but doesn't work if i call a jar method.
View Replies
View Related
Feb 20, 2014
I have just tried to learn java this week [COLOR="#000000"]and I am being held back by this once installed java jdk I nav to the java file and the bin file and then the javac file to find that the below tab does not exist
A new window should pop up giving the properties of the javac, there should be an attribute called Location..I can see the location option in my documents but in no other folder
View Replies
View Related
Jul 11, 2014
So I have an Enum file with 119 constants and each constant of that type has 20 fields that come with it. All the fields are the same type and named the same (e.g. there are 119 of Object obj, one for each constant), and I want to run the same methods over them. Since the Objects of the same type are named the same for each constant, I just have them named explicitly in get-er methods.
This worked fine when I just put all 20 fields through the constructor and set them as fields under all the constants. But I realized that if I wanted to make an instance of this Enum class, I'd have to enter in all 20 fields when they are all a set of Objects with unique values. So I then put them as fields under their own respective constant to make it easier to create instances of this enum. But now my methods don't work.
A) I don't really understand why they don't work anymore?
B) Is there a way to fix it without putting all the methods under each constant?
Example:
public enum MyEnum {
AAA {
private MyObject obj = new MyObject (3.0);
},
BBB {
private MyObject obj = new MyObject (1.5);
},
CCC {
private MyObject obj = new MyObject (6.5);
},
DDD {
private MyObject obj = new MyObject (3.5);
};
public double getObjVal() {
return obj.value(); // it can't find this obj should I move it up to where the constants are declared?
}
}
View Replies
View Related
Mar 4, 2015
How do I get java to tell me what it thinks the current deployment configuration properties are? I'm aware of Deployment Configuration File and Properties and see it tells me what the values are, how to set them, etc. But what I want is a way to run java and have it cough up what it's currently using. Something like 'java -display-config-properties' and have it spit out all current values it's using.
View Replies
View Related
Jun 8, 2014
I am wondering why in the example below the opacity is interpolated from the start value to the specified keyframe value but the width is not. It just jumps to the keyframe value right on button click.
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
[Code] .....
View Replies
View Related
May 2, 2014
I would like to know whether I should use properties and observable collections when creating a domain model for a new application using FX? I have read up quite a bit on the topic, but I can't find any clear answers. Most forums tend to suggest that the domain model should NOT contain properties, since this does not encourage a loose coupling of the model and the view. The alternative however is to write wrapper classes for each POJO in my domain model. This is however a lot of duplication, and it requires a complete listener system to ensure that the wrapper classes are in sync with the model classes.
View Replies
View Related
Dec 17, 2014
In my project I need to create a pizza ordering system. I have created a array list of pizza toppings and each pizza topping must have a cost property associated with it, then the user can pick the toppings they want and the cost of each topping will be added up and the total cost of the whole pizza will be displayed. But I don't know how to associate a cost with each topping. I have been told that I can access the cost through a get/set method and store it in a private member variable. But I don't know how to do this?
I've tried to do it, but it hasn't worked. This is the code
public void setCost( double cost){ //my get/set method
this.cost = cost;
}
public double getCost(){
double price = 0;
return price;
[Code] .....
But there is an error on each of the ingrediantCost method lines, saying
The primitive type double of cost does not have a field Pepperoni
...and the same for chicken, ham and onion.
View Replies
View Related
Jan 31, 2011
In my java app there is a code which reads the properties file from src/main/resources folder.
Java Code:
@Component("mailerProperties")
public class MailerProperties {
private static Properties properties;
public MailerProperties() {
properties = new Properties();
[Code] ....
Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.
Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file...
View Replies
View Related
Aug 26, 2014
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//find selected command
String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a properties file and if it exists, pull the key and the value back into a panel
View Replies
View Related
Jan 22, 2014
I have `country.properties` file which have values as follows:
1=USA
91=India
20=Egypt
358=Finland
33=France
679=Fiji
and, have a response class file, which is setting a response from database to display it on `JSP` file. The value that I am getting from database is in the form of `code` or `integer`. I needed to have that value from the database and before setting the response I need to use `getProperty(code)` and save the String representation of that code into a new list and then pass that list to `setResponse`. For e.g: This is the value I am getting from database:
col1 | col2 | col3 |
1 helo done
I needed to show on my JSP page as:
col1 | col2 | col3 |
USA helo done
I was following this tutorial [URL].... but not able to exactly understand how to achieve the same.
This is my `DAOImpl` where I needed to `iterate` and save the `mapped key-value` in a new list and then pass to `JSP` page
public class CountDAOImpl implements IDataDAO {
private Connection conn = null;
private Statement statement = null;
private ResultSet rs = null;
private List<String> country_code = new LinkedList<String>();
[Code] ....
View Replies
View Related
Aug 26, 2014
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//find selected command
String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a proeprties file and if it exists, pull the key and the value back into a panel ....
View Replies
View Related
Feb 4, 2015
I'm currently working on a java project simply to learn java. So far, it creates a window and makes a properties file, or appends data to it if it already exists. The problem is that I'm not quite sure how to check if the file already exists to append data to it. I'm currently using a boolean (configCreated) that appends data when true, and creates a file when false. The problem is that this boolean is always false since it's at the beginning.
Java Code:
package Setup;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
[code]...
View Replies
View Related
Mar 26, 2014
Whenever I am running applet using appletviewer I am getting the below warning message:
Can't read Appletviewer properties file.
How to correct this?
View Replies
View Related
Dec 19, 2013
When we have a property in the jnlp file that has accented characters (i.e. Mañana), the System.getProperty() call is returning null. This is working fine with Java 7 Update 40, and accented characters in the <information> section of the jnlp file are working fine under Java 7 Update 45, but not in the <resources> section.
Here is an example:
<property name="jnlp.title" value="Mañana"/>
System.getProperty("jnlp.title") returns null
Is there a workaround?
View Replies
View Related
Jun 3, 2015
I am parsing an XML file. i.e.
<people>
<person firstname="John" lastname="Doe" age="50" />
<person firstname="Thomas" lastname="Jefferson" age="260" />
<people>
I have created Person.java with the following attributes:
private String firstName;
private String lastName;
private int age;
My main method parses the XML, loops through each person, and gets the attributes for each.
I need to create instances of my Person class. I could write something like this:
Person person = new Person();
for (int i = 0; i < attributes.getLength; i++) {
if (attribute.getName(i) = "firstname") { person.firstName = attribute.getValue(i);}
if (attribute.getName(i) = "lastname") { person.lastName = attribute.getValue(i); }
if (attribute.getName(i) = "age") { person.age = attribute.getValue(i); }
}
Since my actual XML has quite a few attributes, I would rather do something like this:
Person person = new Person();
for (int i = 0; i < attributes.getLength(); i++) {
person[attribute.getName(i)] = attribute.getValue(i);
}
This doesn't work.
View Replies
View Related
Nov 27, 2014
I need to write the exact directory path like C:LisaestUpdate to a properties file.
I am trying it by
FileInputStream in = new FileInputStream(test.properties);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(newprop.properties);
props.setProperty("myDirectory","C:Lisa estUpdate" );
props.store(out, null);
out.close();
but the properties file is updated as C:Lisa estUpdate
Extra comes before :.
How can I remove that.
Even I tried it with an command but got same output.
View Replies
View Related
May 29, 2014
I have seen in some examples like URL... a good design is to have the model and the action methods in one just single bean and the model not to be a separated class but a few properties like this:
public class CustomerBean implements Serializable{
//DI via Spring
CustomerBo customerBo;
[b]public String name;[/b]
[b]public String address;[/b]
//getter and setter methods
[code]...
Some questions:
1. If you are using hibernate or any other ORM like the above example(URL...), why not to use the hibernate pojo bean directly like it represented the form instead of using properties?:
public class CustomerBean implements Serializable{
//DI via Spring
CustomerBo customerBo;
[b]Customer customer;[/b] //represents the properties of a form
//getter and setter methods
public void setCustomerBo(CustomerBo customerBo) {
this.custom
2. Why is it said that JSF represents the purest MVC? Spring separates the model from the view too and Struts does too. I dont really understand it
View Replies
View Related