Question: 2)Create a class with main method. Inside the main method, print out all the system properties. And then set a new property, key is myJavaClassHomeDir

2)Create a class with main method. Inside the main method, print out all the system properties. And then set a new property, key is "myJavaClassHomeDir" point it to a special directory on your file system. 3)Create a new properties file , inside that file there is a property maxStringLength = 10. Your program read that property and the get the input from console. If the string input is more than 10 , output a message and truncate the string to 10 characters. 4)Use the Runtime class to execute a command to rename a file on your file system. ---------------- I have some of this written out, but getting stuck on the 3, and 4 part.

Here is my code (1 Class so far):

import java.util.HashMap;

import java.util.Map;

public class Properties {

public static void main(String args[]){

Map env = System.getenv();

for (String enName : env.keySet()) {

System.out.println("Enviromental Properties");

System.out.format("%s=%s%n", enName, env.get(enName));

}

System.out.println(" System Properties");

System.getProperties().list(System.out);

System.out.println(" Setting MyJavahomeClassDirectory");

System.setProperty("myJavaClassHomeDir", "c:\\test");

System.out.println(System.getProperty("myJavaClassHomeDir")); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!