Get System Properties from RuntimeMXBean in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

353 Views

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();To get the system properties, use the getSystemProperties() method −System.out.println("System properties from RuntimeMXBean: "+runtimeMX.getSystemProperties());The following is an example −Example Live Demoimport java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class Demo { public static void main(String args[]) throws Exception { RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean(); System.out.println("System properties from RuntimeMXBean: "+runtimeMX.getSystemProperties()); } }OutputSystem properties from RuntimeMXBean: {awt.toolkit=sun.awt.X11.XToolkit, file.encoding.pkg=sun.io, java.specification.version=1.8, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, java.class.path=/home/cg/root/GNUstep/Library/Libraries/Java:/usr/GNUstep/Local/Library/Libraries/Java:/usr/G NUstep/System/Library/Libraries/Java::/usr/share/java/mysql-connector- java.jar:.:/var/www/html/lib:/var/www/html/lib/dom4j-1.6.jar:/var/www/html/lib/guava- 18.0.jar:/var/www/html/lib/jackson-all.jar:/var/www/html/lib/jaxen- 1.1.4.jar:/var/www/html/lib/jcommon.jar:/var/www/html/lib/jdom2- 2.0.5.jar:/var/www/html/lib/jfreechart.jar:/var/www/html/lib/junit-4.12.jar:/var/www/html/lib/spymemcached- 2.10.3.jar:/var/www/html/lib/stax-1.2.0.jar:/var/www/html/lib/xstream-1.4.7.jar:/var/www/html/lib/gson- 2.3.1.jar:/var/www/html/lib/hamcrest-core-1.3.jar, java.vm.vendor=Oracle Corporation, ... Read More

Implement Keyword Search in MySQL

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

2K+ Views

To implement a keyword search in MySQL, you can use LIKE operator. The syntax is as follows −SELECT *FROM yourTableName where yourColumnName Like ‘%anyKeywordName%’ or yourColumnName Like ‘%anyKeywordName%’;To understand it further, let us first create a table. The following is the query to create a table −mysql> create table KeywordSearchDemo    −> (    −> StudentId int    −> ,    −> StudentName varchar(100)    −> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using INSERT command. The query to insert record is as follows −mysql> insert into KeywordSearchDemo values(100, 'Adam John'); Query OK, 1 ... Read More

FTP fput Function in PHP

Samual Sam
Updated on 30-Jul-2019 22:30:24

167 Views

The ftp_fget() function is used to upload from an open file and saves it to a file on the FTP server.Syntaxftp_fput(con,remote_file,open_file,mode,startpos);Parameterscon − The FTP connectionremote_file − The file path to upload toopen_file − The open local filemode − The transfer modestartpos − The position to begin downloading fromReturnThe ftp_fget() function returns TRUE on success and FALSE on failure.ExampleThe following is an example wherein we will download server file “demo.txt” and save it to open local file “new.txt” −

Get Absolute Path of a File in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

2K+ Views

The method java.io.File.getAbsolutePath() is used to obtain the absolute path of a file in the form of a string. This method requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       File file = new File("C:" + File.separator + "jdk11.0.2" + File.separator, "demo1.java");       System.out.println("The absolute path name is: " + file.getAbsolutePath());    } }The output of the above program is as follows −OutputThe absolute path name is:/C:/jdk11.0.2/demo1.javaNow let us understand the above program.The absolute pathname of the file is ... Read More

Get JVM Uptime from RuntimeMXBean in Java

Samual Sam
Updated on 30-Jul-2019 22:30:24

382 Views

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine −RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();Let us get the JVM uptime using the getUptime() method −runtimeMX.getUptime()The following is an example −Example Live Demoimport java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class Demo { public static void main(String args[]) throws Exception { RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean(); System.out.println("JVM Uptime = "+runtimeMX.getUptime() + " ms"); } }OutputJVM Uptime = 81 msLet us run the code again, to get the following output −JVM Uptime = 78 ms

Remove All Elements from TreeSet in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

494 Views

Use the clear() method to remove all elements from TreeSet.First, create a TreeSet and add elements −TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); set.add("27"); set.add("89"); set.add("57");Now, remove all the elements −set.clear();The following is an example to remove all elements from TreeSet −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]){ TreeSet set = new TreeSet(); set.add("65"); set.add("45"); set.add("19"); set.add("27"); ... Read More

Begin Auto Increment from a Specific Point in MySQL

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

341 Views

To begin auto increment from a specific point, use ALTER command. The syntax is as follows −ALTER TABLE yourTableName auto_increment = anySpecificPoint;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table AutoIncrementSpecificPoint −> ( −> BookId int auto_increment not null, −> Primary key(BookId) −> ); Query OK, 0 rows affected (0.56 sec)Now you can insert records using insert command.The query is as follows −mysql> insert into AutoIncrementSpecificPoint values(); Query OK, 1 row affected (0.17 sec) ... Read More

Applications of Laser Technology

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

769 Views

LASER is an acronym for Light Amplification by Stimulated Emission of Radiation. The LASER action was first proposed by Einstein.Applications of a LASERA LASER can be used in many fields. Some of its usages are given here.Used In Welding and Melting: The laser beam welding is mainly used for joining components using high welding speeds and low thermal distortion.Used In Holography: The reason that a hologram cannot be made without a LASER source is that coherence length for laser source can be very high due to which sustained interference pattern will be recorded on a hologram. This suggests the indispensable ... Read More

Android Character by Character Display Text Animation

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

804 Views

This example demonstrate about How to make Android character by character display text animation.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       Typewriter writer = new Typewriter(this);       setContentView(writer);       writer.setCharacterDelay(150);       writer.animateText("Sample String...Sample String...Sample String...");    } }In the above code, ... Read More

Why Zero (0) is the First Number

Rani RPS
Updated on 30-Jul-2019 22:30:24

3K+ Views

Zero (0) is used as a number and also as the numerical digit. Zero gives the additive identity of the integers, real numbers, and many algebraic structures. It is used as a placeholder for writing numbers.Natural numbers start from 1, then 2 and so on. We cannot count backward with them. Integers, on the other hand, allows us to count backward. Zero winds up being a good choice for the number that should come after 1 as we count backward. Integers can go in both directions, to a positive infinity and also in the reverse direction to a negative infinity. ... Read More

Advertisements