How to read domain information in java

I need a java code implemented as follows.
When the java code runs in a particular machine, the domain which this machine belongs needs to be read.
The domain information can be easily retrieved using the wmi. But how java can implement it?
Thanks in advance.

WMI stands for Windows Management Instrumentation (WMI). We can view or manipulate any information made available through WMI (including the domain information) through vbscript. In order to retrieve the informationthrough wmi, the vbscript needs to be launched in the java.
Do we have a java's native way to retrieve domain from windows machine?

Similar Messages

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • How To Read RTF file in JAVA?  Using  iText?

    How To Read RTF file in JAVA?  Using  iText?.....
    import java.io.*;
    import com.lowagie.text.*;
    import com.lowagie.text.rtf.*;
    public class RTF3 {
    public static void main(String[] args) {
    // System.out.println("This example generate a RTF file name Sample.rtf");
    // Create Document object
    Document myDoc = new Document();
    try {
    // Create writer to listen document object
    // and directs RTF Stream to the file Sample.rtf
    RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
    // open the document object
    myDoc.open();
    // Create a paragraph
         Paragraph p = new Paragraph();
         p.add("Helloworld in Rtf file..amazing isn't");
         // Add the paragraph to document object
    myDoc.add(p);
    catch(Exception e) {
    System.out.println(e);
    //close the document
    myDoc.close();
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
         at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
         at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
         at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
         at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
         at com.lowagie.text.Document.open(Unknown Source)
         at view.RTF3.main(RTF3.java:23)
    CAN you HELP me?

    import com.lowagie.text.Document;
    import com.lowagie.text.rtf.parser.RtfParser;
    import java.io.FileInputStream;
    String inputFile = "sample.rtf";
    Document document = new Document();
    document.open();
    RtfParser parser = new RtfParser(null);
    parser.convertRtfDocument(new FileInputStream(inputFile), document);

  • How to read system evenlog using java program in windows

    How to read system evenlog using java program in windows???
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Welcome to the Sun forums.
    >
    How to read system evenlog using java program in windows???>
    JNI. (No.)
    >
    is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
    >
    Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
    Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb.

  • How to read pdf files using java.io package classes

    Dear All,
    I have a certain requirement that i should read and write PDF files at runtime. With normal java file IO reading is not working. Can any one suggest me how to proceed probably with sample code block
    Thanks in advance.

    hi I also have the pbm. to read pdf file using JAVA
    can any body help meWhy is it so difficult to read the thread you posted in? They say: java.io is pointless, use iText. So why don't you?
    or also I want to read a binary encoded data into
    ascii,
    can anybody give me a hint how to do it.Depends on what you mean with "binary encoding". ASCII's binary encoding, too, basically.

  • How to read File Header in JAVA

    I wanna upload a(doc/pdf) file from client site, where I hv to check whether the the file is originally a doc/pdf file or not, I mean not just the extension, but the actual header information of the file. Please some body help me to do this, I dont know how to read the file header. Thnx in advnc.

    You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
    ~

  • How to read XML files from java

    i need a sugession that how to read a xml file using java code
    and i need to parse using some parsers and display attributes and entity seperately
    as a string.......

    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.io.SAXReader;
    import java.io.File;
    import java.text.AttributedCharacterIterator.Attribute;
    import java.util.Iterator;
    import java.util.StringTokenizer;
    public class XmlParser
    private String Result="";
    private String Final="";
    private String Delim="";
    public void bar1(Document document) throws DocumentException
    org.dom4j.Element root = document.getRootElement();
    // System.out.println(root.getName());
    bar2(root);
    System.out.println(this.Result);
    process();
    public void bar2(org.dom4j.Element e)
    for(Iterator i = e.elementIterator();i.hasNext();)
    org.dom4j.Element Element = (org.dom4j.Element) i.next();
    Result += Element.getName()+"\t"+Element.getText()+"\n";
    bar2(Element);
    public void process()
    StringTokenizer Tokenizer = new StringTokenizer(this.Result,"\n");
    String element;
    while(Tokenizer.hasMoreTokens())
    element = Tokenizer.nextToken();
    StringTokenizer Tokenizer2 = new StringTokenizer(element,"\t");
    // Do what ever String Process here Example
    this.Final += element.getName();
    this.Final += this.Delim;
    System.out.println(this.Final);
    public static void main(String s[])throws Exception
    Document document = null;
    SAXReader reader = new SAXReader();
    File f1= new File("D:/Rajesh/EDI to XML/EDI.xml");
    document = reader.read(f1);
    Demo obj = new Demo();
    obj.bar1(document);
    i think this will hep full.......

  • How to read my information from a html file?

    Hi
    I saved an html file from a website.
    How can I read my information (For example the first URL) from the html file?
    following code reads line by line:
    using (StreamReader reader = new StreamReader(Application.StartupPath + @"\x.htm"))
    String line = String.Empty;
    while ((line = reader.ReadLine()) != null)
    MessageBox.Show(line);

    How about this...
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Diagnostics;
    namespace ReadFromHtml
    class Program
    static void Main(string[] args)
    using (StreamReader reader = new StreamReader(Environment.CurrentDirectory + @"..\..\..\page1.html"))
    String line = String.Empty;
    while ((line = reader.ReadLine()) != null)
    if (line.Trim().StartsWith("<a"))
    Console.WriteLine(line.Trim());
    break;
    Console.ReadLine();
    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta charset="utf-8" />
    <title>mobile craigslist</title>
    </head>
    <body>
    <h1>PAGE1.HTML</h1>
    <hr />
    <a href="http://mobile.craigslist.com">mobile craigslist</a>
    <hr />
    </body>
    </html>
    UML, then code

  • How to Read An Attachment Using Java Mail

    Hi
    I Am Able To Read The Mail Using Java Mail ,but Unable To Read The Attachment Which Comes Along With The Mail.
    Please Help Me , In Reading The Attachment.

    Hi
    I Am Able To Read The Mail Using Java Mail ,but
    t Unable To Read The Attachment Which Comes Along
    With The Mail.
    Please Help Me , In Reading The Attachment.Do you mean:
    - I only recieve .txt or .doc attachments and I want to see the contents? Or could you get a .jpg as well?
    or
    - Do you need to seperate the attachment from the e-mail and then view it?

  • How to read outlook mail using java

    Hi,
    I am new to javamail ,
    I want to read outlook mail using java
    thanks
    Edited by: My_Problems on Jun 20, 2008 11:13 AM

    Hi!
    See Java Api Msgparser in GNU General Public License...
    A parser for .msg Files in Java :
    [http://auxilii.com/msgparser/|http://auxilii.com/msgparser/]
    Use POI... Apache POI - Java API To Access Microsoft Format Files...
    regards,

  • How to read Korean characters using Java program?

    In Oracle table, i am having Korean characters, how to read those characters using JDBC and insert into SQL Server?
    NLS_NCHAR_CHARACTERSET is UTF8

    What data type is the column in the Oracle table? The NLS_NCHAR_CHARACTERSET would control the encoding of NCHAR and NVARCHAR2 columns. The NLS_CHARACTERSET would control the encoding of CHAR and VARCHAR2 columns.
    Justin

  • How to read "Customixed Information" in UME using WebDynpro Java APIs

    Dear All
    In our Portal UME we have defined 3 custom fields that appear in the "Customized Information"
    tab in the standard Portal "Identity Mangagement" application ie:
    krb5principalname :
    How can I retrieve the custom fields and values using WebDynpro APIs?
    I have the following basic code to retrieve the standard user session information, but
    do not know how to extend it to extract the values of the custom fields.
    Full points will be awarded to whoever answers question with suggestion that works.
    Many thanks in advance
    Mike

    Hi Mike,
    Following code is for just one custom attribute <custom attribute>
                                  String namespaces[] = umeUser.getAttributeNamespaces();
                                  String ns = null;
                                  for (int i = 0; i < namespaces.length; i++) {
                                       if (i > 0)
                                            ns = namespaces[ i ];
                                       String attrNames[] = umeUser.getAttributeNames(ns);
                                       if (ns != null){                                   
                                   if(ns.equals("<name-space>")){     
                                       for (int j = 0; j < attrNames.length; j++) {
                                            if(attrNames[j].equals("<custom attribute>")){                                        
                                                 Object attr[] = umeUser.getAttribute(ns, attrNames[j]);
                                                 for (int k = 0; k < attr.length; k++){
                                                      if(!(null == attr[k])|| !(attr[k].toString().length() == 0)){                                                  
                                                           //attr[k].toString() has the custom attribute value
                                                      break;
                                            }else
                                                 continue;               
                                   }else
                                       continue;
    Where <name-space> is the same value you set in config tool or on portal UME configuration.
    Config Tool: Global Service Configuration>services->com.sap.security.core.ume.service>ume.virtual_groups.user_attribute.namespace
    Portal
    System Administration>System Configuration>UME configuration> User Admin UI tab>
    Custom attributes of the user profile
    Administrator-Managed Custom Attributes: add ;<name-space>:<custom-attribute>
    Hope this helps

  • How to read SGML files using Java

    I've got a text categorisation test collection called Reuters-21578 for my Information Retrieval project. It is distributed in 22 files. Each of the first 21 files (reut2-000.sgm through reut2-020.sgm) contains 1000 documents, while the last (reut2-021.sgm) contains 578 documents. The files are in SGML format. Each of the 22 files begins with a document type declaration line:
    <!DOCTYPE lewis SYSTEM "lewis.dtd"> The DTD file lewis.dtd is included in the distribution. Following the document type declaration line are individual Reuters articles marked up with SGML tags.
    My questions is how to write a java program to read those 21578 documents or transform them into 21578 seperated text files.

    I guess I missed something. What is Renes link?. The
    parser stuff isn't really what I'm looking for. I'm
    a new at and just learning java and I just want to
    know the easiest way to read a SGML file. Should I
    use a buffered Reader with a Pushback Input Stream?Hang on.....you want to just read the file without intelligently extracting the SGML data contained within and so have no need of a parser?
    Well, in that case, its just text.....so just use BufferedReader or whatever to read the text data. If I understand you correctly, all you really wanted to ask was "how do I read a text file?"

  • How to set proxy information in JAVA.NIO framework MINA or Netty?

    Hi all,
    THERE IS NO PROXY SUPPORT VIA JAVA.NIO.
    How to use MINA or Netty,other framework support proxy?
    Thanks in advance!

    The forum is focus on questionNo. The forum is provided by Sun and latterly Oracle to talk about core Java programming: in this case the Java networking APIs. Questions about 3rd party products should be directed to the people who supply them. And asking questions in places where the relevant expertise isn't concentrated is not a rational strategy.
    I think you really need patience as a professional expert.Expert, yes. Professional? Is somebody paying me to post here?
    And don't talk to me about patience. You have already completely exhausted any patience I may ever have had by repeating a question five times after I had already answered it. Judging by the below you are now in the process of repeating that process.
    The information is shared by anybody.Correct, including me, and including the information that there are better places to ask than here about 3rd party products.
    Besides, I think I submitted right question on right place.Then once again you are proving yourself incompetent, as I have already told you that it isn't the right place.

  • How to read Excel file in java

    Respected sir/madam
    I want to read the values from Excel file in Java program. How can I do that. When I searched over the net I came to know that you can treat Excel file as a Database and write the code as u write for making DB connections .
    I did that but i am getting the following error ..can anybody please help..
    This is the code what i have written
    import java.io.*;
    import java.sql.*;
    public class ReadExcelFile {
    Connection c;
    Statement stmnt;
    public void checkABA_Number()
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    c = DriverManager.getConnection("jdbc:odbc:ExcelTest","",""); // ExcelTest is the DSN name
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from abadata"); // abadata is my Excel file name
    while(rs.next())
    System.out.println(rs.getString(1)+" "+rs.getString(2));
    }catch(Exception e)
    System.out.println(""+e.toString());
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    public static void main(String[] args)
    new ReadExcelFile().checkABA_Number();
    My Excel file starts from the first row and first column and also the first row contains the names of the column.
    It give me the following error..
    java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'abadata'. Make sure the object exists and that you spell its name and the path name correctly.
    How can I deal with this.?I have properly selected the worksheet while giving the DSN . Is there any versionig problem with Excel or some drivers are in appropriate..and yes i chose Microsoft Excel Driver (.xsl) from ODBC .
    I created System DSN.
    Can anybody please help me with this ? I will be very gratefull for replies
    Thanks in advance

    here is the code to read excel file
    public void readexel(String filename)
    Connection c = null;
    Statement stmnt = null;
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
    stmnt = c.createStatement();
    String query = "Select * from [Sheet1$]" ;
    ResultSet rs = stmnt.executeQuery( query );
    while( rs.next() )
    System.out.println( rs.getString(1) );
    catch( Exception e )
    System.err.println( e );
    }

Maybe you are looking for

  • USB2 and video in

    hello, I made an upgrade for a G4 Quicksilver with a USB2 PCI card. the name of the card is USB2EHCI. I didn't find anything about this card on internet, in fact I bought it years ago for a Supermac, really never used it as a USB2 hub. now on the Qui

  • Dreamweaver CS3 Stalling when opening html files

    Hello, I have Dreamweaver CS3 running Mac OS X 10.5.2 on a new Mac Pro, and have had no problems until now. All of a sudden, Dreamweaver hangs for between 5 and 10 minutes when opening various HTML files. Once the files are open, generally it's fine,

  • Generating picture on Applet after fetching it from Database

    Hello, I want to display the picture of employee in my JApplet. The data base which I am using is SQL Server 2000.I will be storing it under image data type in data base. How will I retrive the picture of employee when Employee I.D is selected. Any c

  • How do I place an interactive PDF on a webpage in Muse -- so the interactivity still works?

    I have tried to link to the original document but that isn't working -- the video that is in the PDF isn't playing.  If anyone knows how to do this, please let me know!

  • Can't SETCOOKIE with Javascript with SAFARI

    Why can't a cookie be set/read when the HTML/Javascript application (eBOOK) is located on the local file system, or on a local network file server (ie: not a WEB server)? Opera, Firefox work great, but not Safari. This breaks the ability to locally e