A C rotine in Java prog !!!!!

hi...
i have a JAVA prog but i wana insert into a C rotine/Script, how i will do ?????
other thing, can i block the terminal and only liberate the machine if the user type the login and password corectly, the login and password will be signed by a Admin prog in java, the client prog will block the machine and if the user type corectly will request the information by RMI to the admin prog, and if it corectly will free the machine, it is possible ????????

i have a JAVA prog but i wana insert into a C rotine/Script, how i will do It's called JNI:
http://java.sun.com/docs/books/tutorial/native1.1/index.html
I stopped reading the other question after one sentence and a half.
Kind regards,
  Levi

Similar Messages

  • Java prog is very slow

    hai
    i am beginner level in java prog
    i insert data in ms sql server 2000. i am insert 5000 record in database . but i am application take long time .pls give advise for me
    very quick
    import java.sql.*;
    public class SqlDatabase
              public Connection connection;
              public boolean openConnection(String strServerIPAddress, String strDatabaseName, String strUserName, String strPassword)
                   String url = "jdbc:microsoft:sqlserver://" + strServerIPAddress + ":1433" +";DatabaseName=" + strDatabaseName;
                             try
                             //Loading the driver...
                             DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
                             //Buiding a Connection
                             connection = DriverManager.getConnection(url, strUserName, strPassword);
                             if(connection== null )
                             return false;
                             //catch( java.sql.SQLException e )
                             catch (SQLException e)
                             System.out.println(e.getMessage());
                             return false;
                             return true;
              public void SqlDataInsert(String Random_num,String Check_Sum)throws Exception {
                   //DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
                   //Connection connection = DriverManager.getConnection( "jdbc:microsoft:sqlserver://202.146.65.221:1433;DatabaseName=MMS_Gateway","Tech","tech32132");
                        if (connection != null)
                             try {
                                  Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
                                       ResultSet resultSet = stmt.executeQuery("select * from Random_CheckSum where 1=2");
                                       resultSet.moveToInsertRow();
                                       resultSet.updateString("Random_Number",Random_num);
                                       resultSet.updateString("Check_Sum",Check_Sum);
                                       resultSet.insertRow();
                                       System.out.println("Data Sroted in Database");
                                  } catch (SQLException e) {
                                       System.out.println(e.getMessage());
    }

    now my java prog is very fast . now take 15 sec to 20 sec for insert 5000 records
    now i have change my code is
    import java.sql.*;
    public class SqlDatabase
              public Connection connection;
              public boolean openConnection(String strServerIPAddress, String strDatabaseName, String strUserName, String strPassword)
                   String url = "jdbc:microsoft:sqlserver://" + strServerIPAddress + ":1433" +";DatabaseName=" + strDatabaseName;
                             try
                             //Loading the driver...
                             DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
                             //Buiding a Connection
                             connection = DriverManager.getConnection(url, strUserName, strPassword);
                             if(connection== null )
                             return false;
                             //catch( java.sql.SQLException e )
                             catch (SQLException e)
                             System.out.println(e.getMessage());
                             return false;
                             return true;
              public void SqlDataInsert(String Random_num,String Check_Sum)
                   if (connection != null)
                              try {
                                   String Sql="INSERT INTO Random_CheckSum (Random_Number, Check_Sum) VALUES(?, ?)";
                                        PreparedStatement pstmt =connection.prepareStatement(Sql);
                                        pstmt.setString(1, Random_num);
                                        pstmt.setString(2, Check_Sum);
                                          pstmt.executeUpdate();
                                       System.out.println("Data Sroted in Database");
                                  } catch (SQLException e) {
                                        System.out.println(e.getMessage());
    } Thank for all

  • Launching another prog from java prog

    Hi!
    I'm striving to format floppy disk from a java prog.
    format, like many other commands/applications, sends some messages back to the terminal and waits for user input. I need to handle communication with such programs.
    So far it doesn't go smooth - please look at the code below, there must be number of bugs:private static void execute(String command) // command="cmd.exe /c format A:"; (Win2k)
         try {
         String outp_line;
            Process process = Runtime.getRuntime().exec(command);
         // put process input in BufferedReader
         BufferedReader normalBR =
              new BufferedReader(new InputStreamReader(process.getInputStream()));
         // "format A:" on win2k sends to console 2 lines:
         // 1. Insert disk in drive A:
         // 2. and press ENTER
         // but I see only one(first) line. Why?
         while ((outp_line = normalBR.readLine()) != null)
                        System.out.println(outp_line);
         // assign an output stream to the process
         BufferedOutputStream bos = new BufferedOutputStream(process.getOutputStream());
         // assign input from user to BufferedInputStream
         byte[] bytes = new byte[12];
         BufferedInputStream bis = new BufferedInputStream(System.in, 12);
         // read user's input
         bis.read(bytes);
         // write user's input to the process
         bos.write(bytes);
         }catch(IOException ioex){ioex.printStackTrace();}

    Don't know about the first thing, but I saw this in the API:
    "The Runtime.exec methods may not work well for special processes on certain native platforms, such as native windowing processes, daemon processes, Win16/DOS processes on Microsoft Windows, or shell scripts. The created subprocess does not have its own terminal or console. All its standard io (i.e. stdin, stdout, stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream(), Process.getInputStream(), Process.getErrorStream()). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock."
    I'd suggest googling for a workaround.
    Re: the second item, I think another thread makes sense. Perhaps a thread that reads all the error output and stores it in a buffer, which could then be queried.

  • Calling Servlet from a java prog?

    Hi all,
    I am calling servlet from a java prog (Java Agent in Lotus Notes) by using URL and URLConnection object. how can i trigger the Servlet By using doPost method .I have to send some parameter also.
    Thanx
    Muthu

    you need to open a connection to the servlet. Then you must call getInputStream() and getOutputStream() and use them in any way you see fit. I was trying this before and could not get POST to work unless I openned the input stream from the servlet. Strange... but doGet worked without openning the input stream???
    // open a connection....
    // write to the servlet
    servletConnection.getOutputStream().write("whatever");
    servletConnection.getOutputStream().flush();
    servletConnection.getOutputStream().close();
    // grab what the servlet sends back, required to do a post.
    byte [] in = new byte[100];
    servletConnection.getInputStream().read(in);
    servletConnection.getInputStream().close();

  • Through a java prog how to execute a unix script ?

    Hi !! I am a Java Developer . I have to work in Unix and Java in combination. Can you plz suggest me a solution for the below queries --
    1. Through a java prog how to execute a unix script.
    2. How to send the o/p of the script to a java prog so that it can be used in the java program to the prupose of display etc..

    Try this
    Process process = Runtime.getRuntime().exec("ps -ef");//write Your command here
                   InputStream in = process.getInputStream();
                   BufferedReader bufReader = new BufferedReader(new InputStreamReader(in));
                   String data=null;
                   while((data = bufReader.readLine())!=null)
                        System.out.println(data);   //do whatever you want to do with the output

  • Erase a file from a java prog?

    Hello.
    Is it possible to erase an image in a directory from a java program? Or do I have to create a shell script that I call in the java program?
    I saw somewhere on the web that it wasn't possible to call a shell script from a java prog, so if there's a method in java that does it, I would be glad to know it. Any help would be appreciated.
    Many thanks
    Philippe

    thanks, guys.
    But I get a io.FilePermission... with the two methods.
    I checked my permissions, and it's all right
    what's happening?What do you mean by "I get a io.FilePermission" ?
    What exactly do you get ?
    Which two methods are you talking about ?
    If the file can't be deleted the file may be used by another ( hanging) process.

  • What happen when i compile a java prog.

    I, to an extend know how to code using java. However I don know what really happens after compiling a java prog and what happens when i run it.. what is JVM, JDK, JIT etc., means.. What is a class file and a jar file and a war file.. I'm confused.. ANy help is really appreciated..
    Thanks in advance..
    regards.

    Java source is compiled into "portable byte code" (a class file).
    The JVM (virtual machine) interprets the "portable byte-code" into "machine instructions"... The actual instructions may vary from platform to platform, but the contract is they will allways have the same effect.
    JIT stands for "Just In Time"... as usually means "JIT-compiler"... which is fancy pants name for an interpreter.
    Google will tell you more.

  • Read lines from text file to java prog

    how can I read lines from input file to java prog ?
    I need to read from input text file, line after line
    10x !

    If you search in THIS forum with e.g. read lines from file, you will find answers like this one:
    Hi ! This is the answer for your query. This program prints as the output itself reading line by line.......
    import java.io.*;
    public class readfromfile
    public static void main(String a[])
    if you search in THIS forum, with e.g. read lines from text file
    try{
    BufferedReader br = new BufferedReader(new FileReader(new File("readfromfile.java")));
    while(br.readLine() != null)
    System.out.println(" line read :"+br.readLine());
    }catch(Exception e)
    e.printStackTrace();
    }

  • Calling C prog. from Java prog.

    Hi.
    I have a java GUI program as a interface. User can enter data, then java prog calls a C program and at the end the java GUI shows the returned parameters of C prog. The question is: how can I call C prog from Java GUI?
    Thanks

    "Calling a program" is not standard terminology, so I'm not sure what you're asking.
    Do you want to call a function in a DLL (most likely written in C) inside your Java code? Yes, that's JNI.
    Or do you want to execute a program (which may happen to have been written in C, but the language doesn' matter) from inside you Java code? That's [Runtime.exec|http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html].

  • Calling existing C/C++ dll from Java Prog

    Hi,
    From within the Java code I want to use the
    functionality of an existing C API. The dll's of C are available. Is it possible to directly call the C Api using Jni or some other technique or do I need to implement a native method in C which would Use the existing C Api to get the values and Pass them to the Java prog.
    Istikhar.

    Is it possible to directly call the C Api using Jni...Depends on what you mean. You can't call it directly from java. You can use JNI, including C/C++ to call it.

  • Executing a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say that the Perl program that I want to execute is 'abc'.'abc' requires some input that I want to give from within the java program. How do I do that? Then I want to execute the Perl program from within the Java prog. How do I do it?

    don't crosspost.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=427211&tstart=0&trange=100

  • Java prog as service

    I have written a java prog and created its .exe version using jar command.I want to run this prog as a background process.I came to know that if i run it as a service (windows 98) then it might help.Is it true?
    if yes , how can I run that .exe file as a service?

    Thanks for your suggestion.Infact I had that requirment of starting it everytime my machine starts.But I already have done it.Problem is my prog uses MSPAINT to perform a task.So that MSPAINT window pops up everytime which i dont want.Evenif I use javaw instead of java the window pops up.How can I thwart it?

  • How to run a java prog from c prog

    hello all
    I wanted to run a java class from a c prog,
    can any body suggest the way in which this can be done, links or tutorials in this regard is highly appreciable,
    thanks in advance
    Message was edited by:
    mahima_vyas

    Let's say that the order of arguments is as below
    1. Jar file name
    2. Classpath
    Your shell script would look like this
    java -cp $CLASSPATH:$2 -jar $1 I am assuming that your jar file has the required main-class entry in its manifest. Note that $1...$9 represent the arguments to this shell script.
    The same goes for a batch file
    java -cp %CLASSPATH%;%2 -jar %1

  • Any way to run a JAVA prog in background? (like SETI)

    Does anyone know if it's possible to have a java program only run during otherwise idle cpu cycles?
    I have a program which does an awful lot of number crunching, and needs to run for long periods of time. Ideally I want it to function in the same way as programs like the Search for ExtraTerrestrial Intelligence (SETI) program or cancer research programs, in so far as they will only run when the cpu has little else to do, thereby not hogging all my system resources when I need to do something else.
    Failing that, is there a way to make my program resumable? i.e, is there some way to save the exact execution state of the program on exiting, and have it resume from where it left off at a later date?
    Any help would be much appreciated.

    Yes, but not by using Java.
    Unfortunately, Sun and its key developers have decided to hide behind the rhetoric of claims of lack of portability as a means to avoid providing a full and complete programming solution, forcing people like me, who have to write code that really does run everywhere and really does do sophisticated things to implement our own solutions beyond Java - this is one of those (thankfully few) times when you must do so.
    I am working on a code-set of some twenty five thousand lines of Java (or more - NONE of that including GUI code!) that also has to handle such concerns. Our solution is to use operating system tools to solve this problem. We have settled on the unix paradigm for our solutions, primarily because there are (now) unix or unix-like solutions available for every computer operating system that has at least a 1% installed base or market share of existing boxes out there today. For Windows, we have our customers use CYGWIN - check it out, it's good stuff. For Apple, you've now got OSx...
    Note also that you may wish to break your threads away from user interaction. For this, we use "nohup" - a part of the unix paradigm! Works great but you must be sensitive to the fact that you have to point the tool at a log-file, and there are miscellaneous rules for that logfile... Pay attention to such issues and a solution isn't very hard.
    ...Oh, one more thing: To launch your code from a running Java thread you must beware of how Java captures the runtime environment and, in short, makes your life miserable. A good solution for this is to run a "shell script" that then does what you want, completely outside of Java. This has the advantage of letting YOU choose the run-time environment variables that are or are not set, and what their values are, instead of letting Java constrain you. ...Note that we use this technique for going TO Java FROM Java! We just use a but of operating system help in the middle! WORKS GREAT!
    I hope this helps.
    Regards,
    Richard

  • Java.io.filepermission error while executing a batch file from java prog

    Hi,
    i want run a java program which executes a batch file, both are in a jar file. while am trying this using webstart it shows error:access denied java.io.filepermission <<ALL FILES>>execute. why this happens how to rectify this.
    By
    Vinod

    Clearly, it would be a security vulnerability to be able to do such a thing from the web w/o user granting trust to the application.
    Java Web Start applications run in the Java SE secure sandbox unless they have been granted all-permissions by the user:
    1.) sign all jar files.
    2.) add <security><all-permissions/></security> to the jnlp file.
    The user would then be prompted to grant trust to the applications.
    /Andy

Maybe you are looking for