How do i make UNIX system calls in Java app?

Is it possible to make UNIX system calls in a java app? I.E. perform a file copy/move to another machine within a program.
Thanks,
Erik

If there is a command line tool then you use Runtime.exec() otherwise you have to use JNI.
If you want to access shared libraries you might want to look at www.swig.org

Similar Messages

  • Unix System Calls using Java

    Hi!
    Can anyone tell me how to do Unix System Calls in my Java program?
    If possible please give me the java code for it taking one unix system call as an example.
    Thanks in advance
    Raj

    do you mean firing off a shell command, or making actual kernel API calls or C library calls?
    for shell commands, have a look at Runtime.exec(). for kernel calls, use JNI. the JNI FAQ mentions something called "shared stubs" that may be of use:
    http://java.sun.com/products/jdk/faq/jnifaq.html
    cheers,
    p

  • How do I make a phone call from my mac with yosemite?

    How do I make a phone call from my MacBook Pro on the Yosemite operating system?

    The following quotation is from Connect your iPhone, iPad, iPod touch, and Mac using Continuity
    There is more information in the link, including supported hardware and that you must have Settings > FaceTime > iPhone Cellular Calls set to on on the iPhone.
    Phone calls
    With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
    To make and receive phone calls, here's what you need:
    Sign in to the same iCloud account on all your devices, including your Mac.
    Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
    All devices must be on the same Wi-Fi network.
    All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
    Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
    Make a call
    To make a phone call on your Mac, iPad or iPod touch tap or click a phone number in Contacts, Calendar, or Safari.

  • How to access system calls from java program?

    i am having a doubt regarding accessing system calls from a Java program like accessing unix system calls from a c program.

    Runtime.getRuntime().exec("line command here");
    example:
    Runtime.getRuntime().exec("ls -la");

  • System call fom Java code

    Hi all
    I hope someone over here might answer my problem.
    I need to run a Shell script form my Java code, which does perform some operations like writing/copying files to a specific directory and my Java code then starts reading the files and do necessary stuff like parsing it for some info inside the file.
    If I make a system call from my Java code, how do I know when the shell script is done executing completely? Just to make sure that my Java code execution starts only after the shell script has executed.
    If anyone has come across such a scenario, please reply to this topic. A sample code wud be a bonus for me :)
    Thanks
    -Uday

    If you've never used Runtime.exec, read this carefully first:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    MOD

  • System Call by Java Application - [change path and run of the other progra]

    public class  A {
         public static void main (String[] args)
              System.out.println("Hi");
    }I do have above A.java.
    I am generating A.class from it.
    A.class is in the following directory :
    /home/sachin/work/Sample_Directory/bin/hello_filetest/
    I have another program which makes System call.
    But the problem is B.java is in the different directory :
    /home/sachin/work/Sample_Directory/src/hello_filetest/
    public class  B {
         public static void main (String[] args) {
    Process p1 = Runtime.getRuntime().exec("java A);
                BufferedReader stdInput = new BufferedReader(new
                     InputStreamReader(p1.getInputStream()));
    while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
    {code}
            So, my question is how to change directory by system calls and execute the program
    which is lying in other directory ????
    Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    The following code will call javac on a .java file, which will compile it into a .class file
         public static void javacTest() {
              JFileChooser jf = new JFileChooser();
              if (jf.showOpenDialog(null) != jf.APPROVE_OPTION) return;
              File file = jf.getSelectedFile();
              File dir = file.getParentFile();
              try {
                   Process p = Runtime.getRuntime().exec("javac " + file.getName(), null, dir);
                   IOUtils.pipe(p.getInputStream(), System.out);
                   IOUtils.pipe(p.getErrorStream(), System.out);
              catch (IOException iox) {
                   iox.printStackTrace();
         }Is that what you're trying to do, or are you trying to run the compiled (.class) file? Running your .class file should be basically the same as the above, assuming that you are not using any non j2se libraries, except that you need to take into account the package (if package is x.y, you must have file in ...src\x\y\foo.class - call "java x.y.foo" from src)

  • Unix script call from java applet

    In perl you can use the system command to call a unix command like mv or ls. How do run a unix command from a java applet?

    normaly java applets are not allowed to execute any code. But there is a possibility to ask the user to be allowed to..
    in Netscpae you can use the following:
    import netscape.security.PrivilegeManager;
    then somewhere in the class...
    PrivilegeManager.enablePrivilege( "UniversalExecAccess" );
    then the user can press 'grant' or 'deni'. If he pressed grant, you can do the following:
    Process process = Runtime.getRuntime().exec( "command" );
    //where command is what ever command you like to execute
    hope that helps.
    lexip

  • Issuing Solaris system calls through Java

    How can I issue a system call to Solaris using Java? (i.e. Start a script, open a file, and similar)

    Hi Srini,
    This is just a suggestion, but try entering the following commands (in your SQL*Plus session) before executing your stored procedure:
    set serveroutput on size 1000000
    exec dbms_java.set_output(1000000)Hope this helps.
    Good Luck,
    Avi.

  • How i can make  my own connection in java source of a jsp page

    How i can make my own connection in java source of a jsp page (How to get connection from JNDI datasource address) ?
    imagine that i have a rowset in a web page , now i want to do some operation using
    plain JDBC , so i will need a connection object.
    I tried to get one of my rowsets connection but it return null ?
    what is best way to retrive a connection from JNDI datasource that we define for our project?
    for example if i have
    myRowSet.setDataSourceName("java:comp/env/jdbc/be");
    in web page constructor
    now i want a pure connection from the same datasource ? JNDI
    Thank you

    It is not hard to get your own connection from datasource.
    in your case you need to do like the the following code.
    i provide sample to show you how to catch the exception and create an statement .
    Connection con =null;
    try{
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/be");
    con = ds.getConnection();
    java.sql.Statement st =con.createStatement();
    }catch(SQLException sqlex){
    sqlex.printStackTrace();
    sqlex.getNextException().printStackTrace();
    catch(NamingException nex){
    nex.printStackTrace();
    hth
    Masoud kalali

  • How do I make document folders in adobe reader app on iPad? Thanks

    How do I make document folders in adobe reader app on iPad? Thanks

    First show the Documents list, and in the upper left tap the Edit button. A toolbar in the upper left you'll see a folder icon with a + superimposed. Tap that and you'll be prompted to Create a Folder. Enter the folder name and tap the Save button and your new folder will appear in the Documents list.

  • How we can update the  System Date,in java

    Hi guys,
    can U pls help me...
    How we can update the System Date,in java
    I need to get the System Date and time continuosly thruogh threads concept.kindly help me
    Thanking u in Advance

    System.currentTimeMillis() will give you the current
    system date and time as a long value.
    ~I think the OP wants to change the system time not just get the system time.

  • How can i make Apple id free for downloading apps

    how can i make free apple ID for downloading apps?

    No thats false thers an other way go to App Store ( on iphone or itunes) then choose any free app click download the App Store will ask you for your apple id the click in this dialog on create new apple id then you should select by Credit Card None, thats a trick, you don't need a credit or itunes card
    PS: Sorry for my bad english

  • How do i make an official complaint about an app? They have stopped access to my account and are trying to extort money via paypal (skirting Apple) to allow me access again!! Who might i contact regarding this behavior? Does Apple have a code of ethics!

    Hello community!
    How do i make an official complaint about an app? They have stopped access to my account and are trying to extort money via paypal (skirting Apple) to allow me access again!! Who might i contact regarding this behavior? Does Apple have a code of ethics required for apps?
    Ive used this app for a couple years now, invested a significant amount of money developing my account over that time (close to a couple of grand id say). The Apps support wont discuss the situation, just demand the cash to reopen my account. There is no anual fee or anything.... Its extrordinary behavior to now be faced with this loss of investment.
    I dont wish to go into more detail in the public domain but your help in directing me to the apropriate contact/department would be greatly apreciated. I'm located in Australia.
    Best regards,
    Mike

    All I can suggest is to contact iTunes. You should not have been able to create a new account with the same email address
    Apple - Support - iTunes - Contact Us

  • How do i make sure that my creative cloud apps are RTL (hebrew) compatible?

    how do i make sure that my creative cloud apps are RTL (hebrew) compatible?

    In your Creative Cloud Desktop app choose Preferences, then under Apps,
    choose this App Language:
    Then each app you want will have an Install button next to it.
    After installing, go into Preferences for each app. Under Interface, choose English (Hebrew) for the UI language,and under Type, select Middle Eastern. Restart, and be sure your OS is set up for Hebrew.

  • How to set "Dirty" view flag to make a system call WDDOMODIFYVIEW again

    Hi!
    When a button is hit I want to mark my view "Dirty" so that system call WDDOMODIFYVIEW again. I need this to refresh/rebuild the view after user action.

    Anurag, you right. I've created simple WD application and WDDOMODIFYVIEW is called after every button hit.
    But it my case I've added button to a standard component (FPM_OIF_COMPONENT) by means of Enhancement Points. And hitting this button does not lead to call of WDDOMODIFYVIEW method. Though all standard buttons in the componend do lead to call of this method.
    Strange behavior.
    I thought, may be there is a way to "force" system to invoke this method. Like set view to some status "Needs to be redrawn", "Dirty", "Invalid", etc.

Maybe you are looking for

  • How to avoid white lines

    Hi All, How to avoid the white lines below the selection-options text in the selection screen of the report? I am seeing light while lines below each selection-options or parameters text Thanks aRs

  • Issue on VA01

    To all, As I try to create sales order document by VA01, I get an error message 'The material entered is not allowed for the transaction because the listing is missing.'. Which 'Listing'  does the message mention? Could anybody let me know which tabl

  • How do I redownload Photoshop Elements after my computer has wiped?

    My computer hide drive failed so it was wiped. I have the serial number of my photoshop elements and was wondering where I can go to redownload the software.

  • How does sapinfo.exe works?

    Can any one explain how the tool <b>sapinfo.exe</b> works? If any one has any document regarding this tool(how it works) please share the same with me. Thanks, cvr/

  • Add country to BT108S_LEA component search criteria

    Hi, This is of immediate requirement... I need to add for lead search, the attribute COUNTRY in the search criteria.... I found the BOL entity as BTQLeadDoc...so I will find its structure and enhance it... But further I have no idea...I need to use a