Java applet - Connection with OS

I wrote some Java code to get the date and time via a NTP server.
I get the correct date/time from the server and store it in a variable.
Now I woudl like to pass the value to the 'date' command on the OS (Suse Linux), using JNI.
Two problems:
- How do I get the program to have root access to the 'date' command to change the date and time ?
- How do I execute the 'date' command from within Java ?
Thanks,
J.M.

Try asking this question on one of the Java developer forums. Specificlly the native method forum:
http://forum.java.sun.com/forum.jsp?forum=52

Similar Messages

  • Java Applets connecting to Oracle DB thru OAS (JNDI)

    i am developing an application, like i said before, i am using three applets, one controls a webcam, (records an image to disk and oracle), another controls a Electronic signature pad (records an image to disk and oracle), and finally a finger print reader (the same with this), at the beginning i didnt have any problem at all connecting this applet to the database, but top management wants to do things in another way, not allowing me to connect the applet directly to the database for security reason, My app resides on Oracle Application Server, and i use DataSource and Connection Pooling,
    I want that this applets use the available datasource on OAS to connect to the Database, due that the DataBase IP Address wont be public but OAS IP address will, I know that i must use JNDI to accomplish this, but i didnt have any results at all
    Message was edited by:
    efebo_abel2002

    i retrieved all the datasources from my app and i got this, i show my code and the returned errors, I can't connect my applet to the DB thru OAS datasources, any suggestions?
    package rdf.struts.ajax;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NameClassPair;
    import javax.naming.NamingEnumeration;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class ConductoresClient2 {
    public static void main(String [] args) {
    try {
    final Context ctx = getInitialContext();
    System.out.println(ctx!=null?"ctx no es null":"ctx es null");
    NamingEnumeration nenum=ctx.list("jdbc");
    while (nenum.hasMore()) {               
    NameClassPair entry = (NameClassPair)nenum.next();
    System.out.println("entry:="+entry.getName());
    try {
    DataSource ds=(DataSource)ctx.lookup("jdbc/"+entry.getName());
    Connection conn=ds.getConnection();
    Statement stm=conn.createStatement();
    ResultSet rs=stm.executeQuery("SELECT * FROM palic_ow.conductores");
    while(rs.next())
    System.out.println("rs.getString(1):="+rs.getString(1));
    System.out.println("rs.getString(2):="+rs.getString(2));
    System.out.println("rs.getString(3):="+rs.getString(3));
    catch (Exception e) {
    System.out.println("Exception conectando a la base :"+e);
    //java:comp/env/
    }catch (Exception e) {
    System.out.println("Exception obteniendo Context "+e);
    private static Context getInitialContext() throws NamingException {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"oracle.j2ee.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL,"oc4jadmin");
    env.put(Context.SECURITY_CREDENTIALS,"admin");
    env.put(Context.PROVIDER_URL,"ormi://localhost:23791/sertracen");
    return new InitialContext( env );
    ctx no es null
    entry:=OracleDS
    Exception conectando a la base :javax.naming.NamingException: Lookup error: javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]; nested exception is:
         javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable] [Root exception is javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]]
    entry:=v8PooledDS
    Exception conectando a la base :javax.naming.NamingException: Disconnected: java.lang.NoClassDefFoundError: javax/resource/Referenceable
    entry:=caom
    Exception conectando a la base :javax.naming.NamingException: Lookup error: javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]; nested exception is:
         javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable] [Root exception is javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]]
    entry:=v8DS
    Exception conectando a la base :javax.naming.NamingException: Lookup error: javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]; nested exception is:
         javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable] [Root exception is javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]]
    entry:=v8CoreDS
    Exception conectando a la base :javax.naming.NamingException: Lookup error: javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]; nested exception is:
         javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable] [Root exception is javax.naming.NamingException: javax/resource/Referenceable [Root exception is java.lang.NoClassDefFoundError: javax/resource/Referenceable]]
    Process exited with exit code 0.
    null

  • Did the markup for java applets change with version 4.0.5

    Starting with Safari version 4.0.5 java applets are not rendering correctly. The Java coffee cup loading image pushes the actual content down. Was the applet tag markup changed with this release?
    Take a look at the following example:
    http://tinyurl.com/p27vpq
    or
    http://preview.tinyurl.com/p27vpq
    FYI, 4.0.4 displays correctly.

    Ok...
    First, try a different user account with Safari and see if the same thing happens. If it does then it's a system wide issue, not just your user account.
    From the Safari Menu Bar, click Safari / Empty Cache. When you are done with that...
    From the Safari Menu Bar, click Safari / Reset Safari. Select the top 5 buttons and click Reset.
    Go here for trouble shooting 3rd party plugins or input managers which might be causing the problem. Safari: Add-ons may cause Safari to unexpectedly quit or have performance issues
    Web pages now include a small icon or 'favicon' which is visible in the address bar and next to bookmarks. These icons take up disk space and slow Safari down. It is possible to erase the icons from your computer and start fresh. *To delete Safari's icon cache using the Finder, open your user folder, navigate to ~/Library/Safari/ and move this file "webpageIcons.db to the Trash.*
    Relaunch Safari.
    If you still have problems, go to the Safari Menu Bar, click Safari/Preferences. Make note of all the preferences under each tab. Quit Safari. Now go to ~/Library/Preferences and move this file com.apple.safari.plist to the Desktop. Relaunch Safari. If it's a successful launch, then that .plist file needs to be moved to the Trash.

  • Applet connection with DB

    Hi Guys,
    I have designed an applet and have placed in the htdocs of Apache server that comes with Oracle 9iAS when I can login to the db within my Lan it works fine but when I try to login from outside LAN through a dialup modem I get following error:
    Error in Connecting to the Database java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    I know applets can only communicate with the server they are downloaded from, I have the DB on this same server where I am downloading applet from!
    I am using a router to connect the server to the internet and have opened ports 7777, 4443 and 1521.
    Any1 Any ideas??????????????
    Thanx!

    The error you are getting is a client side error, you will find no log in the listener. The applet demo was tested. The only thing I can think of is the classpath, please make sure your HTML code is pointing to the right ones. Also, you may want to make sure your browser is compatible with the version of the classes you are using, I thought browsers today support jdk 1.1.
    -Soulaiman
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by kibito:
    Since two weeks we are trying to get
    a connection working within an applet with our db.
    Plattform: Linux RedHat 6.1
    Database: oracle8i
    jdk: 1.02 (the classes102.zip)
    webserver: Apache 1.3
    browser: netscape 4.6
    We have always the no suitable driver exception!
    We worked thought different tries:
    - with the JdbcApplet.java Sample from Oracle
    - with the DriverManager.registerDriver
    (new oracle.jdbc.dnlddriver.OracleDriver()); approach
    - with the Class.forName( "oracle.jdbc.dnlddriver.OracleDriver" ); approach
    - with the driver = new oracle.jdbc.dnlddriver.OracleDriver(); approach
    - we tried every possible kind of
    getConnection method
    Questions:
    1. Is it possible to connect from an applet (jdk1.02) to an oracle8i database running under redhat 6.1?
    2. The No suitable driver means for me,
    that the listener has not found a
    driver handling the TCP request for our
    connection. Is this correct?
    3. The listener works like the inetd.
    It gets a connection forks the
    requested process to handle the connection.
    Is this correct?
    4. Even if I check the listeners logs and
    traces, there is never a request arriving
    from my applet. What am I missing?
    Help would be great!
    <HR></BLOCKQUOTE>
    null

  • Java applet crashing with Workgroup Managed machines

    Hi,
    One of my clients uses a Java-based online proofing system for their publications which consistently crashes. We have narrowed the problem to machines that are or have been under Workgroup Management (the problem persists even after machines are unbound). We have eliminated other culprits such as Netinstall, Radmind, browser and Java versions and so on. The applet consistently gives the following output in console log (where the reference to the display profile is specific to that machine):
    2008-11-10 13:54:03.239 Safari[672] * _NSAutoreleaseNoPool(): Object 0x55a68c0 of class NSView autoreleased with no pool in place - just leaking
    2008-11-10 13:54:03.239 Safari[672] * _NSAutoreleaseNoPool(): Object 0x67d13f0 of class NSConcreteValue autoreleased with no pool in place - just leaking
    2008-11-10 13:54:03.240 Safari[672] * _NSAutoreleaseNoPool(): Object 0x40c140 of class NSCFNumber autoreleased with no pool in place - just leaking
    2008-11-10 13:54:03.240 Safari[672] * _NSAutoreleaseNoPool(): Object 0x4ee7e0 of class NSConcreteValue autoreleased with no pool in place - just leaking
    2008-11-10 13:54:03.240 Safari[672] * _NSAutoreleaseNoPool(): Object 0x6727190 of class NSCFDictionary autoreleased with no pool in place - just leaking
    2008-11-10 13:54:03.243 Safari[672] Path /Library/ColorSync/Profiles/GENDISP7.icm
    And when the applet finally crashes we get this:
    2008-11-10 13:44:43.004 Safari[672] * Assertion failure in -[NSViewHierarchyLock unlockTopMostReader], AppKit.subproj/NSViewHierarchyLock.m:444
    The most conclusive test I performed was taking a machine that had never been bound to the server. The applet worked fine with no console log output. As soon as I bound it to the server, the above started happening. I have also found the problem in Tiger and Leopard networks. I have tried obvious stuff like re-creating the display profile.
    Has anyone else seen anything like this? Or can anyone suggest where to look?
    Thanks,

    Java Preferences should be in Applications > Utilities.
    Check the boxes to enable.
    I'll refer you back to the earlier posts of that thread for restting the browser plug-ins.

  • Applet connection with a servlet.

    hi all.
    i need to send data from an applet in the client side to a servlet on the server.
    i want to send this data via http so i won't have to get around firewalls and other problems that might come up if i'll use sockets.
    i'm sending objects, like this: (applet side)URL url = new URL("http://localhost:8080/examples/servlet/ImportListener.Listener");
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    OutputStream out = con.getOutputStream();
    ObjectOutputStream objStream = new ObjectOutputStream(out);
    objStream.writeObject(record);i have two questions:
    (1) how do i get this object data in the servlet??? will it be in the doGet() method?
    (2) how can i send a confirm message back to the applet?
    thanks!

    Hi!
    I have implemented such case, and I thought it might be so helpful for all to post the solution over here, I will provide two cases in one example, first, the applet will send parameters within the posted URL, and in this case you can retrieve them in doGet method, another case is to write objects over output streams, and in this case it will be sent to the servlet using POST method, because the GET method does not have a body which must be exist to handle the streams, so, the whole request will be sent over POST method, and to get it, fill up your Java doPost():
    NOTE: Any object you want to send/retrieve over a network MUST be serializable, which means, the class must implement java.io.Serializable.
    The Applet - CLIENT
    ================
    public boolean getSomeInformation(Object myObject)  {
            // Get a backend connection, see the connect() method below
            URLConnection connection = connect("/myAliasServlet?myname=nabieh&myage=28");
            BufferedReader servletResponse = null;
            ObjectOutputStream oos = null;
            try {
                oos = new ObjectOutputStream(connection.getOutputStream());
                // serialize the object
                oos.writeObject(myObject);
                oos.flush();
                // Read the response from the servlet:
                servletResponse = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String response;
                String s = "";
                while (null != ((response = servletResponse.readLine()))) {
                    s += response;
                if (s != null) {
                    if (s.equals("SUCCESS")) {
                        executed = true;
                    } else {
                         // s = "null"!
                        JOptionPane.showMessageDialog(myForm, s, "Error", JOptionPane.ERROR_MESSAGE);
                        executed = false;
            } catch (IOException ioe) {
                ioe.printStackTrace();
            } finally {
                try {
                    if (oos != null) {
                        oos.close();
                    if (servletResponse != null) {
                        servletResponse.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
            return executed;
    public URLConnection connect(String alias) {
            URLConnection connection = null;
            String serverContext = "http://192.168.0.2:8888/MyApp";
            // Connecting to the server:
            try {
                String s = serverContext + alias;
                URL url = new URL(s);
                connection = url.openConnection();
                connection.setDoInput(true);
                connection.setDoOutput(true);
                connection.setUseCaches(false);
                connection.setRequestProperty("Content-Type", "application/octet-stream");
            } catch (MalformedURLException murle) {
                murle.printStackTrace();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            return connection;
        }The servlet, server side:
    ===================
    Here, the servlet reads the object, do some process whatever it is, pass back a String to the client, the applet.
    protected void doPost(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException {
                    // Get both passed parameters, myname and myage
                     String name = request.getParameter("myname");
              String age = request.getParameter("myage");
                   // Get the seializable object
              ObjectInputStream ois = new ObjectInputStream(request.getInputStream());
              MyObject mo = null;
              try {
                   mo = (MyObject ) ois.readObject();
              } catch (IOException ioe) {
                   System.out.println(ioe.getMessage());
              } catch (ClassNotFoundException cnfe) {
                   System.out.println(cnfe.getMessage());
              // Do whatever you want over here...
                    String found = doSomeThing(mo); // This method gonna return a string, "SUCCESS" or "null".
                    PrintWriter pw = response.getWriter();
              pw.write(found);
              pw.flush();
              pw.close();
         }Good luck.

  • Configuring Java DB Connections with a DAD

    Is there any possible way in OAS/OC4J a Java web app could access a DAD to retrieve connection information?
    Thanks.

    Hi ,
    I have already solved the problem by simply defining a different database user each db connection is based on....
    However , the question is how could i solve - if i could- this kind of problem , simply by defining the same db user on all db connections.....If i have understood your post this could be done via the use of BPEL Process Manager.....
    However , i thank you very much for your interest.....
    Simon

  • Inputstream.java.io.IOException  ,  applet connection

    I'm working on a problem with the failure of a java
    applet connection to a java servlet.
    The connection is via the internet, and over port 80.
    the java console loggin reports the following
    There was an attempt to redirect a url request,
    but the attempt was not allowed by the client. IOException caught in run
    could some one let me know what the URL re-direction is here,
    much apreciated,
    slainte

    I have often found this problem with inexperts java programmers.
    I could tell you better luck next time, but today I feel generous, so I will answer.
    There is a redirect domain problem. When you try to connect the site you receive an ICMP error message, which is the responsable of the error message you can see. That occurs because the URL connects to another URL different (surely because its original URL has changed to another) and you only have to discover the new URL, and try to connect to it.

  • Firefox allows Java Applet with elevated permissions

    I ended up with a virus on Friday when I selected "View" on an HTML attachment from the GMail web interface. The attachment started up java and proceeded to install the malware "Desktop Security 2010" and make changes to my system startup. I'm wondering how this happened and how to prevent it. My java security settings (Java Control Panel->Security->Certificates->Trusted Certificates) only lists Akamai Technologies and JavaFX as trusted certificates. Shouldn't that mean that I get prompted if any one else signs an applet that tries to run outside the sandbox? What else do I need to do to make sure that NO java applets run with elevated permissions?
    I've disabled java via an add-in in the meantime, but what do I need to do to secure my browser properly?
    == This happened ==
    Just once or twice
    == I selected "view" on a virus-infected email attachment in gmail

    Хорошо. Am now able to enter Cyrillic font into my applet. HOWEVER, another issue remains: After pressing enter to process input, new window opens as expected with correct information displaying in window EXCEPT for drop-down menu bar that should display in green square of open window. http://www.lesbaileyev.com/Project/RFvstem.html I will open another suport question for this new development.

  • Keyboard input failure in 2nd java applet

    The (London) Times offers crosswords developed as Java applets. With Mandriva 2007 newly installed on my laptop (Firefox 1.5.0.8, JRE1.5.0_08), I completed one crossword and loaded a second: no keyboard input to cells, no focus shown on cells. Killed the applet, reloaded: same problem. Quit Firefox, restarted crossword: same problem. Quit session, restarted, reloaded Firefox and crossword: same problem.
    Upgraded to Firefox 2.0 and JRE1.5.0_09. Started a crossword with a couple of entries, quit and started a second: same problem - no focus on cell, no input.
    I think this is connected in some way with Mandriva 2007, because the combination Mandriva 2006 with Firefox 1.5.0.7 and JRE 1.4.2-09 works correctly.
    I believe the problem lies initially with Java, because keyboard input to non-Java pages in Firefox worked without problems.

    I have exactly the same problem with opera 9.02 browser, jre1.6, linux debian sarge and the crossword puzzle of "Le Monde" http://www.lemonde.fr/web/article/0,1-0@2-3280,36-139043,0.html
    It worked with jre 1.4 linux FC2, same opera.

  • Java.sql.Connection x J9 VM

    Is possible to use class java.util.Connection with J9 VM using CDC/PP ?
    Logging:
    java.lang.NoClassDefFoundError: java.sql.Connection
    at java.lang.Class.verifyImpl(NativeMethod)
    Help me please;
    Thanks
    []'s

    Is possible to use class java.util.Connection with J9 VM using CDC/PP ?Yes. Check your classpath JARs for java.sql.Connection. You may be missing the jar "database_enabler.jar". See:
    http://blog.vikdavid.com/2005/08/troubleshooting.html
    Vik

  • Applet communication with struts servlet

    Hi
    I�ve seen a lot of examples where a Java applet communicates with a servlet.
    I�ve made a web application using Struts, and i would like to know if it is possible to use an applet (View) and send to Stuts some data, I mean, call an action like http://localhost:8080/ViewRoads.do.
    Is it possible? ,Where can I find some examples about?, could anyone explain how would it work?, any good book to read about?.
    Thank you.

    I'm sorry but don't you have a communication source code example between a servlet and an applet that does work ? I'm looking for one of these since Two days already.
    thanks

  • Exmpl of Servlet connect with ORacle

    Hi folks,
    Can anyone send me example of Java Servlet connectivity with Oracle.
    i m not able to connect servlet with oracle.
    u guys can reply me on [email protected]
    thanks
    dal hit

    No.
    The code for connecting to Oracle from a Servlet is no different from connecting to Oracle from any other Java application. So tell you what, you show us what you've tried and the error message(s) and we'll help you debug it.
    99.999% of the time it's a failure to put the driver Jar file into the classpath, the specifics of which vary from application server to application server. Which one are you using?
    u guys can reply me on [email protected]
    We can, but we won't. This is not your personal bugfixing service. Pay if you want that kind of help. If you want it for free, do it through the forums or go away.
    Probably you'll never read this response, but that's your problem not mine.

  • DataSocket & Java Applet

    Is it possible to program a java applet to access information from instruments using DataSocket? Is there an API? There is an API announced on this website:
    http://flagpole.mit.edu/applets/DataSocket/DS-HOWTO.html
    It says it's a Beta but I cannot acces the link that redirect on NI's Website

    Hi GGingras,
    National Instruments used to provide and support a product known as DataSocket JavaBean. Unfortunately, it has been discontinued. So, DataSocket is not much of an option. There are a few other ways, however, that you can take to gain access to instruments.
    One way would be to create a Remote Panel, which does not need a java applet. Here is a link to a tutorial on how to create one.
    If you must use Java, you could export your LabVIEW VIs into a DLL using Application Builder, and then use the JNI (Java Native Interface) to talk to this DLL. Here is a link that may provide some more information on how to do this.
    Lastly, you can communicate over TCP/IP. You can write a server using TCP/IP primitives and have the java applet connect to it and exchange data via TCP or UDP.
    Hope this helps. Let me know if you need any more information. Happy Coding!
    Jeremy L.
    National Instruments
    Jeremy L.
    National Instruments

  • Create a file at a Windows Vista using java applets

    I have created a java applet which is downloaded to create local file at a Windows Vista PC. The java codes are:
    File out = new File("c:/users/test/hkuesd.properties");
    FileWriter fw = new FileWriter(out);
    PrintWriter pw = new PrintWriter(fw, true);
    pw.println("#sample property file");
    pw.println("key_path=C:/");
    pw.close();
    fw.close();
    If I turn off "Users Account Control" under "Control Panel" --> "User Accounts", the file "hkuesd.properties" is created at c:\users\test and can be found using windows explorer.
    However, if I turn on "Users Account Control", I can not find the file "hkuesd.properties" using windows explorer. But the file can be detected if I run another java applet program with the following codes:
    File xpdir = new File("c:/users/test/hkuesd.properties");
    FileInputStream fis = null;
    if (xpdir.exists()) {
    try {
    fis = new FileInputStream("c:/users/test/hkuesd.properties");
    Properties p = new Properties();
    p.load(fis);
    fis.close();
    privateKeyPath = p.getProperty("key_path", "no value");
    catch (Exception e) {}
    Interestingly, if "Users Account Control" is on and I created the file "c:\users\test\hkuesd.properties" manually, the file creation codes
    mentioned above seems to create another "hkuesd.properties" at the same "c:\users\test". The evidence is I run the second java applet program which can detect the one created by the first java applet but not the one I created manually.

    I agreed that it is hardly explained in words. I
    suggested to write two
    simple java applets using the codes and you will see
    the effects:
    (1) the first applet can create a file
    "hkuesd.properties"
    (2) cannot find the file using windows explorer to
    search the whole drive.
    (3) However, can read the content of the file using
    second applet.You still haven't address your problem of swallowing exceptions. Your code might be throwing an exception that tells you exactly what the problem is. Change your code to display or log that exception.

Maybe you are looking for

  • Problem printing page numbers in black and white

    Using Pagemaker 7.0 and creating a PDF file that I send to a printer. The interior pages of this newsletter get printed in black and white.  The page numbers do not show up in the black page number background oval.  The printer says that that is beca

  • Management console 3.0 Java Errors

    I have just installed Sun Management Console 3.0 and the install reported no errors When I go to start the console es-start -c I get a list of fonts not installed and the a list of Java errors. The path for the fonts seems correct in the startup.prof

  • Internet Explorer 9 crashes with webutil

    Hi, i installed webutil kit on windows vista 32 bits business editions. The installation was successful. Jacob sign was ok too. I have forms 10g 10.1.2.3.0 Installed pacth 7384879 and was ok Forms and Reports 10g work nice on internet explorer 9 and

  • Nike Settings Greyed Out on iPhone 4S

    I have an iPhone 4S, and I wanted to use my Nike + sensor with it (I've been using a nano up to now). I go into settings, Nike +, and the on/off switch is greyed out, along with all the other settings. The only thing tappable is "Go to Nike +". I sho

  • Mp4 exporting problems

    I always recceive error messages when I´m trying to export projects with certain effects into the mp4 format. (crossfade or other basic effects). How can I handle this?