How can I get system properties?

Hello,
How can I get the system properties like %JAVA_HOME% in my java codes, for example, I want to print it like this.
System.out.println("%JAVA_HOME%");
but it doesn't work!
Please give me a hand!

To pass the Operating system environment variable to the Java "environment variables", you have to explicitely pass them on the command line eg.
java -Dmyjava.home=%JAVA_HOME% myClass
then, in your code use
String JAVA_HOME = System.getProperty ( "myjava.home" );regards,
Owen

Similar Messages

  • How can i get system variable using java

    Hi,
    I just want to know how can i get system variables using java code.
    for example i want to get the the date for today or i want to get the number of processes that's running.
    Thanks alot

    Hi,
    I just want to know how can i get system variables
    using java code.
    for example i want to get the the date for today or i
    want to get the number of processes that's running.
    Thanks alotSome generic "system variables" are available though Java, usually through the System class.
    Date today = new Date();
    is instantiated with the current date and time.
    Other system values, like environment values, should be passed to java through the command line (-D option) by setting system properties.
    Finally, platform specific values like the number of processes running will have to be written in platform specific code and executed by JNI (java native interface).
    Java is platform or system agnostic. Common system values, like time, are implemented. Hopefully you won't need platform specific values.

  • How can I  get System dates  with time scheduler using threads

    how can I get System dates with time scheduler using threads.is there any idea to update Date in my application along with system Date automatic updation...

    What the heck are you talking about and whatr has it to do with threads?
    Current time: System.currentTimeMillis. Date instances are not supposed to be updated.

  • How can i get system configuration

    how can i get RAM capacity, Hard disk size,cpu speed and list of all software installed in system, is there any method in java so that i can get all these information without JNI or JNI wrapper , if anybody know please help me
    thanks

    This will work for u
    import java.util.*;
    import java.io.*;
    class SystemTest
         public static void main(String []s)
         Properties pr=new Properties();
         pr=System.getProperties();
         pr.list(System.out);
         System.out.println("\n"+ (Runtime.getRuntime().totalMemory())/(1024*1024) +" M Bytes");
         System.out.println("\n"+ (Runtime.getRuntime().maxMemory())/(1024*1024) +" M Bytes");
    }

  • How can I get list properties using SharePoint CSOM

    Hi Team,
    I am using SharePoint CSOM to read SharePoint Discussion board.I need discussion discription and created by and Discussion list Title etc.
    But I am unable to read those. I saw below message for discussion list in immediate window while debugging.
    DiscussionList
    {Microsoft.SharePoint.Client.List}
    base {Microsoft.SharePoint.Client.SecurableObject}: {Microsoft.SharePoint.Client.List}
    AllowContentTypes: 'DiscussionList.AllowContentTypes' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    BaseTemplate: 'DiscussionList.BaseTemplate' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    BaseType: 'DiscussionList.BaseType' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    BrowserFileHandling: 'DiscussionList.BrowserFileHandling' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ContentTypes: {Microsoft.SharePoint.Client.ContentTypeCollection}
    ContentTypesEnabled: 'DiscussionList.ContentTypesEnabled' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Created: 'DiscussionList.Created' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DataSource: 'DiscussionList.DataSource' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DefaultContentApprovalWorkflowId: 'DiscussionList.DefaultContentApprovalWorkflowId' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DefaultDisplayFormUrl: 'DiscussionList.DefaultDisplayFormUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DefaultEditFormUrl: 'DiscussionList.DefaultEditFormUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DefaultNewFormUrl: 'DiscussionList.DefaultNewFormUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DefaultViewUrl: 'DiscussionList.DefaultViewUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Description: 'DiscussionList.Description' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Direction: 'DiscussionList.Direction' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DocumentTemplateUrl: 'DiscussionList.DocumentTemplateUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    DraftVersion
    EffectiveBasePermissions: 'DiscussionList.EffectiveBasePermissions' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    EnableAttachments: 'DiscussionList.EnableAttachments' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    EnableFolderCreation: 'DiscussionList.EnableFolderCreation' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    EnableMinorVersions: 'DiscussionList.EnableMinorVersions' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    EnableModeration: 'DiscussionList.EnableModeration' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    EnableVersioning: 'DiscussionList.EnableVersioning' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Fields: {Microsoft.SharePoint.Client.FieldCollection}
    ForceCheckout: 'DiscussionList.ForceCheckout' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Forms: {Microsoft.SharePoint.Client.FormCollection}
    HasExternalDataSource: 'DiscussionList.HasExternalDataSource' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Hidden: 'DiscussionList.Hidden' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Id: 'DiscussionList.Id' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ImageUrl: 'DiscussionList.ImageUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    IsApplicationList: 'DiscussionList.IsApplicationList' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    IsCatalog: 'DiscussionList.IsCatalog' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    IsSiteAssetsLibrary: 'DiscussionList.IsSiteAssetsLibrary' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ItemCount: 'DiscussionList.ItemCount' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    LastItemDeletedDate: 'DiscussionList.LastItemDeletedDate' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    LastItemModifiedDate: 'DiscussionList.LastItemModifiedDate' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    MultipleDataList: 'DiscussionList.MultipleDataList' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    NoCrawl: 'DiscussionList.NoCrawl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    OnQuickLaunch: 'DiscussionList.OnQuickLaunch' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ParentWeb: {Microsoft.SharePoint.Client.Web}
    ParentWebUrl: 'DiscussionList.ParentWebUrl' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    RootFolder: {Microsoft.SharePoint.Client.Folder}
    SchemaXml: 'DiscussionList.SchemaXml' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ServerTemplateCanCreateFolders: 'DiscussionList.ServerTemplateCanCreateFolders' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    TemplateFeatureId: 'DiscussionList.TemplateFeatureId' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Title: 'DiscussionList.Title' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    UserCustomActions: {Microsoft.SharePoint.Client.UserCustomActionCollection}
    ValidationFormula: 'DiscussionList.ValidationFormula' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    ValidationMessage: 'DiscussionList.ValidationMessage' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'
    Views: {Microsoft.SharePoint.Client.ViewCollection}
    WorkflowAssociations: {Microsoft.SharePoint.Client.Workflow.WorkflowAssociationCollection}
    Please let me know how can I get all discussion Properties.
    Krishnasandeep

    Here is the code snippet which is working
    ClientContext Context = new ClientContext(siteurl);
    Context.AuthenticationMode = ClientAuthenticationMode.Default;
    List DiscussionList = Context.Web.Lists.GetByTitle("4gl-adapter");
    CamlQuery query = CamlQuery.CreateAllFoldersQuery();
    ListItemCollection itemCollection = DiscussionList.GetItems(query);
    Context.Load(itemCollection);
    Context.ExecuteQuery();
    foreach (ListItem thread in itemCollection)
    string threadTitle = thread["Title"].ToString();
    string threadBody = thread["Body"].ToString();
    But if try to below code,
    String DiscussionDesc = DiscussionList.Description;
    I am getting exception.
    Let me know if I am doing wrong anywhere.
    Krishnasandeep

  • How can i get system time and day

    How can i get the system current time and save it into a variable, then get the current day like wednesday and save it into another variable. Can someone teach me how to set this. thanks
    regards,
    albert

    How can i get the system current time and save it
    into a variable, then get the current day like
    wednesday and save it into another variable. Can
    someone teach me how to set this. thanks
    regards,
    alberti've managed to do this but in gui format hope it suites you.
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class time{
         private Container content;
              private JTextField timeField, dateField;
         public static void main (String[]args){
              time t = new time();
              t.TextClockWindow();
              t.showGUI();
         public void TextClockWindow() {
    // Build the GUI - only one panel
    JFrame frame = new JFrame();
    content = frame.getContentPane();
    timeField = new JTextField(6);
    timeField.setFont(new Font("sansserif", Font.PLAIN, 20));
    dateField = new JTextField(6);
    dateField.setFont(new Font("sansserif", Font.PLAIN, 20));
    content.setLayout(new FlowLayout());
    content.add(timeField);
    content.add(dateField);
    // Create a 1-second timer and action listener for it.
    // Specify package because there are two Timer classes
    javax.swing.Timer t = new javax.swing.Timer(1000,new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    Calendar now = Calendar.getInstance();
    int h = now.get(Calendar.HOUR_OF_DAY);
    int m = now.get(Calendar.MINUTE);
    int s = now.get(Calendar.SECOND);
    //String ampm =now.get(Calendar.AM_PM);
    int y =now.get(Calendar.YEAR);
    int mon=now.get(Calendar.MONTH);
    int d=now.get(Calendar.DAY_OF_WEEK);
    dateField.setText(""+y+ ". "+mon+ "."+d);
    timeField.setText("" + h + ":" + m + ":" + s);
    //to dispaly the current date so easily;stvworks
    String rightNow = "" + new Date();
    t.start(); // Start the timer
    }//end constructor
    public void showGUI(){
         JFrame frame = new JFrame("Time Frame.");
              frame.add(content);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
    frame.setResizable(false);
    frame.setVisible(true);

  • How can i extract system properties

    how can i extract OS properties like desktop resolution, type of internet connection, sound capability, browser character settings etc. ??

    type of internet connection,Not possible. You can detect the lack of an active
    internet connection though (figuring out how is left
    as homework for the reader;)),
    sound capability,Nope.
    browser character settings etc. ??Nope.
    Tuomas RintaThanx for replying..
    Are you serious ?? There is no way to check if the system is sound capable or not ? ok for the type of internet connection i thought that you couldn't so...
    as for the existence of an internet connectio....i am not that new...
    Nik

  • How can I get system recovery discs (mailed and/or burned from laptop)?

    I have a family member who is in another state and has a Toshiba C855D-S5100. It is just under 1yr old and is having some issues booting up. She got it from Best Buy and took it to them yesterday. They are currently running a full diagnostic scan and will let us know what the problem is sometime today (virus, bad drive, bad memory, etc.).
    In the meantime, it made me think that we may want to create some recovery discs (if we can). I did this with an older Gateway. It required 4 DVDs. Can this be done with this model? If so, how as it has Windows 8 and I am not real familiar with this operating system just yet.
    If the test comes back and says the hard drive is the issue, the unit will be sent to Toshiba for repair (since there is 2 weeks left on warranty). In addition to trying to create some recovery discs, can we maybe somehow order the actual recovery discs from Toshiba directly (& keep for future purposes if the hard drive fails and gets replaced)? If so, how and where do we go to get these Toshiba recovery discs sent to us?

    The full Specifications for that machine are HERE.
    See the User's Guide starting on page 55 for instructions on "Creating Recovery Media" yourself.
    You can order Recovery Media from HERE. (Scroll down).
    C.B.
    Toshiba Sat. C75D-B7260 Win 8.1 64 Bit--Toshiba Sat. L775D-S7132 Win 7 HP SP1 64 Bit and Win 10 PRO Technical Preview--Toshiba Sat. L305-S5921 Win Vista SP2 32 Bit

  • How can I get System's Date and Convert it to a String?

    Hello there !
    I'm having a bit of a problem. Could anyone help me?
    I want to know how to get Today's Date in a String?
    Just the Date, and here's the trick.... in this precise Format:
    MM/dd/yyyy
    So for today my String should contain the value: "02/02/2007"
    Please help I am still a learner of the Java programming language.
    Thanks in advance

    And in Java 1.5+:System.out.printf("%1$tm/%1$td/%1$tY\n", new java.util.Date());:o)
    ~

  • EF6: How can I get navigation properties automatically updated?

    I've defined the following entities:
    public abstract class EntityBase
    public int Id { get; set; }
    public string Name { get; set; }
    public class Person : EntityBase
    public virtual HashSet<Message> Messages { get; set; }
    public int CountryId { get; set; }
    public virtual Country Country { get; set; }
    public class Message : EntityBase
    public string Text { get; set; }
    public int PersonId { get; set; }
    public Person Person { get; set; }
    public class Country : EntityBase
    internal class TestContext : DbContext
    public DbSet<Person> Persons { get; set; }
    public DbSet<Country> Countries { get; set; }
    Here's my problem: While the Messages.Person navigation property gets automatically updated according to the Messages.PersonId
    foreign key property value when my changes get saved to the database, the Person.Country
    navigation property remains null although the Person.CountryId
    foreign key property is != 0.
    Why is this happening? Why does the Messages.Person navigation property get aligned with the Messages.PersonId
    foreign key property automatically while the Person.Country navigation property does not get aligned with the Person.CountryId
    foreign key property?
    These are the entity values before SaveChanges() is called:
    person.CountryId = 1
    person.Country = null
    message.PersonId = 1
    message.Person = null
    And these are the entity values after SaveChanges() is called:
    person.CountryId = 1
    person.Country = null
    message.PersonId = 1
    message.Person = { Id = 1, Name = "Test" }
    Your help is appreciated.
    Still people out there alive using the keyboard?
    Working with SQL Server/Office/Windows and their poor keyboard support they seem extinct...

    Thank you for replying, Fred.
    Here's the unit test code I'm using (it calls into a repository which more or less simply calls DbSet<Entity>::Add()
    and SaveChanges();.
    [TestMethod]
    public void MessageDbTest()
    using (Repository<Person> rp = new Repository<Person>(true))
    Person p;
    Message m;
    BusinessLayer.TestContext.CreateNewDB();
    rp.AddOrUpdate(p = new Person("Hello", 1));
    Assert.AreEqual<int>(1, p.Id);
    Assert.AreEqual<string>("Hello", p.Name);
    m = new Message("Hello, too", p.Id, "This is a long test message.");
    p.Messages.Add(m);
    rp.AddOrUpdate(p);
    Assert.AreSame(m, p.Messages.Single());
    Assert.IsNotNull(m.Person);
    Assert.AreEqual<int>(1, m.Id);
    Assert.AreEqual<string>("Hello, too", m.Name);
    Assert.AreEqual<string>("This is a long test message.", m.Text);
    p = rp.GetItem(1);
    p.Messages.Single().Name = "This works, too";
    rp.AddOrUpdate(p);
    [TestMethod]
    public void CountryDbTest()
    using (Repository<Person> rp = new Repository<Person>(true))
    Person p;
    Message m;
    BusinessLayer.TestContext.CreateNewDB();
    rp.AddOrUpdate(p = new Person("Hello", 1));
    Assert.AreEqual<int>(1, p.Id);
    Assert.AreEqual<string>("Hello", p.Name);
    Assert.AreEqual<int>(1, p.CountryId);
    Assert.IsNotNull(p.Country); // ** fails ! ***
    Following is a number of screenshots, depicting the entities' properties.
    Please notice the highlighted navigation property values in the Watch window on the right.
    You will notice that while the Messages.Person navigation property gets aligned with the Messages.PersonId
    foreign key property, the Person.Country navigation property does not get aligned with the Person.CountryId
    foreign key property when TestContext::SaveChanges() is called:
    Still people out there alive using the keyboard?
    Working with SQL Server/Office/Windows and their poor keyboard support they seem extinct...

  • How can I get photo properties??

    I want to integrate camera into my application, but "didFinishPickImage" returns only an UIImage object, is it possible to get the exif information of the photo image file?

    So when I tried a few beta versions ago to get at the original image files I was prevented with a pemission denied error (can't remember the exact folder). Obviously before the SDK was released and I was using the jailbroken phone you could easily access the photos on device but since the official sdk i have not been able to. If anyone has successfully accessed the photos with the official sdk that has not been jailbroken on the device (not the emulator) I would be very interested to know.
    Ta
    Manny

  • How can i get the System Time from the other host

    I want to get the System Time from the other host in the LAN,How can I get the Time using Java.
    Such as I am in WIN 2000 and I have a Unix host in LAN, I want to get unix host System time, How can I do it.

    Open a socket to port 13 and read a string with the time.
    -or-
    Open a socket to port 27 and read 4 bytes that are a network order timestamp
    Assuming that your UNIX machine has those services running, most do

  • How can I get all photos from iPhoto to automatically back up to iCloud from my Mac OSX Version 10.6.8 operating system.  Not enough memory to upgrade.

    How can I get all photos from iPhoto to automatically back up to iCloud from my Mac OSX Version 10.6.8 operating system.  Not enough memory to upgrade.

    You can't.  iCloud is not for general file backup from a Mac. It's for backup up and syncing data between mobile devices and and Macs and  The following is from this Apple document: iCloud: Backup and restore overview.
    iCloud automatically backs up the most important data on your (mobile) device using iOS 5 or later. Once you have enabled Backup on your iPhone, iPad, or iPod touch .....
    What is backed up
    You get unlimited free storage for:
    Purchased music, movies, TV shows, apps, and books
    Notes: Backup of purchased music is not available in all countries. Backups of purchased movies and TV shows are U.S. only. Previous purchases may not be restored if they are no longer in the iTunes Store, App Store, or iBookstore.
    Some previously purchased movies may not be available in iTunes in the Cloud. These movies will indicate that they are not available in iTunes in the Cloud on their product details page in the iTunes Store. Previous purchases may be unavailable if they have been refunded or are no longer available in the iTunes Store, App Store, or iBookstore.
    You get 5 GB of free iCloud storage for:
    Photos and videos in the Camera Roll
    Device settings (for example: Phone Favorites, Wallpaper, and Mail, Contacts, Calendar accounts)
    App data
    Home screen and app organization
    Messages (iMessage, SMS, and MMS)
    Ringtones
    Visual Voicemails
    But not from a Mac.  If you want to backup your photos and other important files I suggest you get an external hard drive and use  it with Time Machine.
    OT

  • My apple tv 2 says I can't stream music from my iTunes library on my iMac without settng up iTunes Match. I don't want to set up iTunes match. How can I get back to the pre-Match system which let me just use home sharing to stream music from computer to A

    When I click on the Music tab on my Apple TV 2, a message tells me I have to set up iTunes Match to stream music from my iTunes library on my iMac. I don't want to set up and pay for iTunes Match. How can I get back to the pre-Match system which let me just use home sharing to stream music from computer to Aple TV

    Ditto.
    You need to look for your itunes library under Computers and select it, then music.
    Music column is for web based content not local content, just to confuse everyone.
    AC

  • How can I get back to default in System pref/ displays/ color. iMac 10.9.5

    How can I get back to default in System pref/ displays/ color?  iMac 10.9.5

    Select the iMac option.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

Maybe you are looking for

  • Two Accounts sharing iPhoto library - iPod access rights error solution

    I followed the advice given in http://support.apple.com/kb/HT1198 to share a single iPhoto library on an external drive between two users. It worked well. ...until both my wife and I tried to connect iPods while in our individual logins and attempted

  • Specification of user's servlets

    Hi, I am working on tomcat4.1 and the servlets were also working fine.But in an attempt of doing some R&D I changed my server.xml.Now all the servlets in webapps/examples/ are working fine.But if I create a new directory below webapps like c:\jakart1

  • Applet Problems

    Hi all.... I wonder if anyone could give me any tips about call the following program from an applet? Basically i am going to send a dataset to this program from an applet and i want it to display the graph that is created... I realise i will have to

  • Division in Acess Seq

    Hi All We make made a new Acess Sequnce for Division, But the price procidure is not picking the condition record  proted on Division. Regrads Niti narayan

  • TREX in MSCS ?

    Hi Guys Any experience with TREX-installation in a Microsoft cluster (MSCS) for high availability. I have searched SAP guides and notes, but have not found any information of TREX-installation i a MSCS. Therefor I now ask you if anyone has reallife e