How to retrieve CPU id in linux using java?

Hello everyone!!
I want to retrieve CPU Id from a liux system using java code.
Please reply with code if possible.
Thank you in advance.

Open "/proc/cpuinfo" and parse.

Similar Messages

  • Problem of accesing MS Acess database on Linux using Java

    Below is my java code and errors found. Can anyone guide me tell me what is the problem and how to success access the .mdb file using Java on Linux?
    import java.sql.*;
    class readmdb
    {      public static void main(String[] args)
    {    String url;
    Connection con;
    Statement stmt;
    try
    {     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException e)
    {    System.out.print("ClassNotFoundException: ");
    System.out.println(e.getMessage());
    try
    {     con = DriverManager.getConnection("jdbc:odbc:DRIVER={/usr/local/lib/libmdbodbc.o.O}};DBQ=/home/powerstation/db/Database.mdb");
    stmt = con.createStatement();
    stmt.close();
    con.close();
    catch(SQLException ex)
    { System.err.println("SQLException: " + ex.getMessage());
    Errors messages found after i executed the java code
    shown above on linux platform.
    Exception in thread "main"
    java.lang.NullPointerException
    at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:436)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:153)
    at java.sql.DriverManager.getConnection(DriverManager.java:512)
    atjava.sql.DriverManager.getConnection(DriverManager.java:193)
    at readmdb.main(readmdb.java:27)

    jschell,
    ODBC shell is the odbc.ini or odbcinst.ini? No.
    The shell is something that you explicitly installed. Just like you installed Apache, or perl, or a C++ compiler, or even a CD driver.
    If yes,
    What is the difference between odbc.in and
    odbcinst.ini? No idea. But on a windows box those are ini files that specify odbc info. I don't think ini files are going to help on linux.
    Which of them will be execute when i
    want to establish a connection using "jdbc:odbc:...."
    in DriverManager.getConnection?I am rather sure that neither of them would 'execute'
    >
    Is it MS Access ODBC linux driver is the file like
    libodbc.so, libmdbodbc.so, libmdbsql.so and so on?No idea, but I doubt it.
    What makes you think that you even have a MS Access ODBC linux driver on your box?
    Then, can u tell me which is MS Access ODBC linux
    driver or what is the driver file name for MS Access
    ODBC linux driver?Nope.
    If you installed a MS Access ODBC linux driver, then the ODBC shell will know where it is.
    And if you did install such a driver you should post the link where you got it here, because as far as I know, there is no such driver (nor is there one for MS SQL Server.)

  • Open a PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    One thread is enough:
    http://forum.java.sun.com/thread.jspa?threadID=5267458

  • Open PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    appi wrote:
    Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
    How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ.

  • How to pass Cascading Parameter in SSRS using Java

    How to pass Cascading Parameter in SSRS using Java---
    We are having a problem with dependent parameters.There are three drop down--
    1.first dropdown is of Country.When we select a country--Accordingly next dropdown(State)will populate
    2.Second dropdown is of State. When we select a state--Accordingly next dropdown(City)will populate.
    I have three data sources are
    CountryList-
    SELECT CountryRegionCode, Name
    FROM Person.CountryRegion
    ORDER BY Name
    StateList
    SELECT StateProvinceID, StateProvinceCode, CountryRegionCode
    FROM Person.StateProvince
    WHERE CountryRegionCode = @CountryRegionCode
    ORDER BY StateProvinceCode
    CityList
    SELECT StateProvinceID, City
    FROM Person.Address
    GROUP BY StateProvinceID, City
    HAVING (StateProvinceID = @StateProvinceID)
    ORDER BY City
    Ihave to show report that has been deployed on server on the besis of these parameters
    I am using ReportViewer in JSP Page through url--
    http://192.168.90.149/ReportServer/Pages/ReportViewer.aspx?%2fReport+Project1%2fCascading_Parameters&rs:Command=Render&rs:parameter=true&Country="+Country+"&State="+State;
    But it is not accepting parameter if they are cascaded.It is working fine if Both parameters are independent.
    Edited by: kaushlee on May 11, 2010 9:22 PM

    Take a look at set_custom_property:
    public static final ID SETTEXT = ID.registerProperty("SETTEXT");
    public boolean setProperty(ID pid, Object value)
        if (pid == SETTEXT)
    String text = value.toString();
    and in forms
    set_custom_property('beans.bean_item', 1, 'SETTEXT', 'some text');
    cheers

  • How to Pass Click Value to DB using Java

    How to Pass Click Value to DB using Java and display tat
    clicked value row data in flex
    i have created connection with Sql Server using java and drew
    pie chart from values fetched from XML file created by Java
    wat i need is when i click pie chart region (widget) i should
    display a alert by giving value of particular widget name and Value
    from Database and display in Flex Alert

    Use AddResource to add Javascript in your BackingBean Code and pass the value to your javascript code.
    JSCookMenu and other dynamic adding of javascript to a JSF-JSP page is done using AddResource....

  • How do I produce an excel file using java code

    How do i produce an excel file using java code.
    If it is possible would ne one have ne source code as an example.
    I have tried looking up information on outputing the information to a *.csv file but unfortunality i have had no luck in finding any information. To be exact ne source code.
    Thanks
    Lee

    That's what I use and I'd be the first to admit that it's very messy. But it works. Go use Google and see what else you can find.

  • How to Store word doc in oracle  using java

    hi
    toall
    can any one tell me how to store word doc in oracle9i using java
    bye

    Please refer to
    http://www.databasejournal.com/features/oracle/article.php/3305771

  • How to do transactions in jsp pages using Java & MySQL ?

    Hi,
    I'm a newbie..
    I'd like to know "How to do transactions in jsp pages using Java & MySQL ?"
    Platform: Windows XP, Apache Tomcat 5.5, MySQL 5, Java bean without EJB
    what are the the different types of transactions? Differences between them?Pls provide examples?
    Which among them is the best method to implement a transaction?
    Pls help me...
    thnx in advance...

    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

  • How to extract .sit files(in MAC)  using java program

    Hi,
    please help me , i want to simple program for
    " how to extract .sit files(in MAC) using java program"
    that sit files same as zip files in windows..[                                                                                                                                                                                                                                                                                                                                   

    Thanks for reply...
    but i search in the google about this topic...there is no results will appear..
    the problem is "i have to run program in the MacOS like extract all the
    .sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
    please do the needful..i am waiting for ur reply,,,

  • How to force the Netscape browser to use Java Plug-in 1.3.0_02?

    For Analyzer 6.2.1, how to force the Netscape browser to use Java Plug-in 1.3.0_02?

    Change the classid in the object tag here is some info.This applies to JRE's 1.3.1 and greater.How do I know what Class ID to use for a specific JRE?CAFEEFAC-0013-0001-0004-ABCDEFFEDCBACAFEEFAC = This tells the browser to force a specific JRE0013-0001-0004 = JRE version number 1.3.1_04 (1.3.1_08 would be 0013-0001-0008)ABCDEFFEDCBA = Just needs to be there.1.3.0_02 = E19F9331-3110-11d4-991C-005004D3B3DB, it seems like they did not implement the standard until v.1.3.1Any good JRE Version = 8AD9C840-044E-11D1-B3E9-00805F499D93, this class id will just look for any good JRE.http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/version.html

  • How to get free disk space in linux   Using JAVA program ?

    Hi,
    I am new to such adavance topics.. like JNI
    I have to check linux system free disk space , if space is more than 80% it should email to user.
    But how to check that Using Java program ??
    can u give me one sample example ? i will do it if u can do some for me
    thanks
    give me possible solutions...

    Using the Runtime class you can execute any linux command. Check it out.

  • How to run SQL script file on Linux using Java ?

    Hi,
    I need to execute .sql file using java. I used following approach for this.
    private void runScriptEvent(java.awt.event.ActionEvent evt) {                               
            String sqlOutput = "";
            String sqlPromptLines="";
            String currentFunctionName = "";
            if(con!=null){
                String userName = jTextField4.getText();
                String password = jPasswordField1.getText();
                String databaseName = jTextField3.getText();
                try {
                    String script_location = "";
                    ProcessBuilder processBuilder =null;
                    Process process = null;
                    //File file = new File("C:/ScriptFile");
                    File file = new File("./SQL_Script");
                    //File file = new File("E:\\install\\SQL_Script");
                    if(file.exists()){
                        File [] list_files= file.listFiles(new FileFilter() {
                                        public boolean accept(File f) {
                                        if (f.getName().toLowerCase().endsWith(".sql"))
                                        return true;
                                        return false;
                    int count = 0;
                        for (int i = 0; i<list_files.length;i++){
                            script_location = "@" + list_files.getAbsolutePath();//ORACLE
    //currentFunctionName = list_files[i].getName();
    StringTokenizer st = new StringTokenizer(list_files[i].getName(), ".");
    while(st.hasMoreTokens()) {
    currentFunctionName = st.nextToken();
    String extention= st.nextToken();
    System.out.println("Function Name = "+currentFunctionName + "\t Extention = " + extention);
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLE
    processBuilder.redirectErrorStream(true);
    process = processBuilder.start();
    BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String currentLine = null;
    while ((currentLine = in.readLine()) != null) {
    sqlPromptLines = " "+sqlPromptLines + currentLine +"\n";
    count ++;
    System.out.println(count+" " + currentLine);
    if(currentLine.equalsIgnoreCase("Function created.")){
    sqlOutput = "\n" sqlOutput currentFunctionName + " " currentLine"\n" ;
    break;
    }// end while
    in.close();
    process.destroy();
    }//end for
    }//end if file exists
    } catch (IOException e1) {
    jTextArea1.setText(e1.getMessage());
    System.out.println("Script Done");
    jTextArea1.append(sqlOutput);
    }// end id Connection is not null
    Above code working appropriate on Windows but not on Linux.
    is there any changes needed ?
    Regards,
    Ajay
    Edited by: Ajay Sharma on Nov 21, 2012 6:43 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi gimbal2,
    about code
    jTextArea1.setText(e1.getMessage());I am using this code so that the user will be prompted with a message rather than stack trace.
    About the issue I am getting on linux i believe its because of following statement.
    processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLERegards,
    Ajay
    Edited by: Ajay Sharma on Nov 23, 2012 12:05 PM
    Edited by: Ajay Sharma on Nov 23, 2012 12:06 PM

  • How to set Develoment Environmnet  in Linux using Tomcat for Application

    Hi All,
    I am facing problem while craeting development environment in Linux for Tomcat.
    I have installed Tomcat in /opt/tomcat directory.
    Within Tomcat i made a Application Dir name "eprosys".
    /opt/tomcat/eprosys/WEB-INF/classes
    /web.xml
    and then configure server.xml in conf directory
    <Context path="/project"
    docBase="opt/tomcat/eprosys"
    reloadable="true"
    debug="0"/>
    </Host>
    then i started tomcat
    [root@localhost bin]# ./startup.sh
    Using CATALINA_BASE: /opt/tomcat
    Using CATALINA_HOME: /opt/tomcat
    Using CATALINA_TMPDIR: /opt/tomcat/temp
    Using JRE_HOME: /usr/java/jdk1.5.0_07/
    [root@localhost bin]#
    In catalina.out message which i get.
    Aug 26, 2006 6:39:21 PM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    Aug 26, 2006 6:39:21 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/30 config=null
    Aug 26, 2006 6:39:22 PM org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    Aug 26, 2006 6:39:23 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 17978 ms
    [raingauge] DEBUG [Timer-0] LocationDailyGraphManagerImpl.createLocationDailyGraphs(62) | Location Daily Graph. Creating graphs at Time=Sat Aug 26 18:39:43 IST 2006
    But when i use browser like
    http://localhost:8080/project
    I get this message .
    HTTP Status 404 - /project/
    type Status report
    message /project/
    description The requested resource (/project/) is not available
    So, please help me where i am wrong. Same thing i do in Windows O/s it works.
    But in Linux i face problem,
    Bye,
    Prabhat

    aiGrace wrote:
    I want to set the options "-server -Xms128m -Xmx512m -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=11.40.5.62" as my java default options so that I only have to use
    java -classpath . HelloWorldUse the *nix alias command
    alias java="java -server -Xms128m -Xmx512m -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=11.40.5.62"

  • How to get comparable Oracle JDBC performance using Java 1.4 vs 1.1.7?

    Our application makes extensive use of JDBC to access an Oracle database. We wrote it a number of years ago using java 1.1.7 and we have been unable to move to new versions of java because of the performance degradation.
    I traced the problem to JDBC calls. I can reproduce the problem using a simple program that simply connects to the database, executes a simple query and then reads the data. The same program running under java 1.4 is about 60% slower than under java 1.1.7. The query is about 80% slower and getting the data is about 150% slower!
    The program is attached below. Note, I run the steps twice as the first time the times are much larger which I attribute to java doing some initializations. So the second set of values I think are more representative of the actual performance in our application where there are numerous accesses to the database. Specifically, I focus on step 4 which is the execute query command and step 5 which is the data retrieval step. The table being read has 4 columns with 170 tuples in it.
    Here are the timings I get when I run this on a Sparc Ultra 5 running
    SunOs 5.8 using an Oracle database running 8.1.7:
                     java 1.1.7  java 1.4
            overall:    2.1s         3.5s
            step 1:     30           200
            step 2:    886          2009
            step 3:      2             2
            step 4:      9            17
            step 5:    122           187
            step 6:      1             1
            step 1:      0             0
            step 2:    203           161
            step 3:      0             1
            step 4:      8            15   <-   87% slower
            step 5:     48           117   <-  143% slower
            step 6:      1             2I find the same poor performance from java versions 1.2 and 1.3.
    I tried using DataDirect's type 4 JDBC driver which gives a little better performance but overall it is still much slower than using java 1.1.7.
    Why do the newer versions of java have such poor performance when using JDBC?
    What can be done so that we can have performance similar to java 1.1.7
    using java 1.4?
    ========================================================================
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    public class test12 {
        public static void main(String args[]) {
            try {
                    long time1 = System.currentTimeMillis();
    /* step 1 */  DriverManager.registerDriver(
                        new oracle.jdbc.driver.OracleDriver());
                    long time2 = System.currentTimeMillis();
    /* step 2 */  Connection conn = DriverManager.getConnection (
                  "jdbc:oracle:thin:@dbserver1:1521:db1","user1","passwd1");
                    long time3 = System.currentTimeMillis();
    /* step 3 */  Statement stmt = conn.createStatement();
                    long time4 = System.currentTimeMillis();
    /* step 4 */  ResultSet rs = stmt.executeQuery("select * from table1");
                    long time5 = System.currentTimeMillis();
    /* step 5 */  while( rs.next() ) {
                      int message_num = rs.getInt(1);
                      String message = rs.getString(2);
                    long time6 = System.currentTimeMillis();
    /* step 6 */  rs.close(); stmt.close();
                    long time7 = System.currentTimeMillis();
                System.out.println("step 1: " + (time2 - time1) );
                System.out.println("step 2: " + (time3 - time2) );
                System.out.println("step 3: " + (time4 - time3) );
                System.out.println("step 4: " + (time5 - time4) );
                System.out.println("step 5: " + (time6 - time5) );
                System.out.println("step 6: " + (time7 - time6) );
                System.out.flush();
            } catch ( Exception e ) {
                System.out.println( "got exception: " + e.getMessage() );
            ... repeat the same 6 steps again...
    }

    If I run my sample program with the -server option, it
    takes a lot longer (6.8s vs 3.5s).Which has to be expected, as the -server option optimizes for long running programs - so it shoudl go with my second suggestion, more below...
    I am not certain what you mean by "just let the jvm
    running". Our users issue a command (in Unix) which
    invokes one of our java programs to access or update
    data in a database. I think what you are suggesting
    would require that I rewrite our application to have a
    java program always running on the users workstation
    and to also rewrite our
    commands (over a hundred) to some how pass data and
    receive data with this new server java program. That
    does not seem a very reasonable just to move to a new
    version of java. Or are you suggesting something
    else?No I was just suggestion what you descript. But if this is not an option, then maybe you should merge your java-programs to C or another native language. Or you could try the IBM-JDK with the -faststart (or similar) option. If thew Unix you mention is AIX, then there would be the option of a resetable-vm. But I cannot say if this VM would solve your problem. Java is definitly not good for applications which only issue some unqiue commands because the hotspot-compiler can not be efficiently used there. You can only try to get 1.1.7 performance by experimenting with vm-parameters (execute java -X).

Maybe you are looking for

  • Can't get the software to work with Audigy 2

    Hi, I have had my Audigy 2 ZS going on a year now and haven't had any problems. I recently made a clean install of Windows XP and upgraded to SP2 and all that. Now, I can get sound out of the card but can't get the software to work at all; cannot get

  • How to populate form data in jsf

    Hi I have 2 questions about how to do things in jsf, i have been working with struts and so will give example of what i would do in struts I have a jsf page for login, when i authenticate the next screen is a table with bunch of data, Where do i popu

  • Loud clicking noise right side of printer before print, but prints fine

    Printer started making a loud clicking noise yesterday before each printed page. Extremely loud. I've searched and tried everything in the discussions. Cleaning, putting on its side, shaking it, banging it. Nothing works. Is it just trash now?

  • Unable to boot panther cd's

    I know, second post, but I got a hold of some old panther cd's from school. So I put disk one in.... and hello? Questionmark. I've tried booting it using open firmware too... also using the command "boot cd:,\\:tbxi". I don't know if this will help,

  • Connected wi-fi freezes IMAC

    Hi, I recently had my 10.4.11 installed with more ram and a new hard drive.  The OS is now 10.5.8.  Prior to this work, the system froze up periodically, but the web sites still loaded and fairly quickly.  Now with the rebuild, it constantly freezes