Question about Java Sound example?

Hello,
I found this example AudioPlayer, when searching for an example of how to play .wav files in Java.
The code seems quite long, and wondered if anyone could advise if this is the best way to play a wav file?
And could anyone explain if the EXTERNAL_BUFFER_SIZE should allows be set to 128000;
Thank you
import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
public class SimpleAudioPlayer
     private static final int     EXTERNAL_BUFFER_SIZE = 128000;
     public static void main(String[] args)
            We check that there is exactely one command-line
            argument.
            If not, we display the usage message and exit.
          if (args.length != 1)
               printUsageAndExit();
            Now, that we're shure there is an argument, we
            take it as the filename of the soundfile
            we want to play.
          String     strFilename = args[0];
          File     soundFile = new File(strFilename);
            We have to read in the sound file.
          AudioInputStream     audioInputStream = null;
          try
               audioInputStream = AudioSystem.getAudioInputStream(soundFile);
          catch (Exception e)
                 In case of an exception, we dump the exception
                 including the stack trace to the console output.
                 Then, we exit the program.
               e.printStackTrace();
               System.exit(1);
            From the AudioInputStream, i.e. from the sound file,
            we fetch information about the format of the
            audio data.
            These information include the sampling frequency,
            the number of
            channels and the size of the samples.
            These information
            are needed to ask Java Sound for a suitable output line
            for this audio file.
          AudioFormat     audioFormat = audioInputStream.getFormat();
            Asking for a line is a rather tricky thing.
            We have to construct an Info object that specifies
            the desired properties for the line.
            First, we have to say which kind of line we want. The
            possibilities are: SourceDataLine (for playback), Clip
            (for repeated playback)     and TargetDataLine (for
            recording).
            Here, we want to do normal playback, so we ask for
            a SourceDataLine.
            Then, we have to pass an AudioFormat object, so that
            the Line knows which format the data passed to it
            will have.
            Furthermore, we can give Java Sound a hint about how
            big the internal buffer for the line should be. This
            isn't used here, signaling that we
            don't care about the exact size. Java Sound will use
            some default value for the buffer size.
          SourceDataLine     line = null;
          DataLine.Info     info = new DataLine.Info(SourceDataLine.class,
                                                             audioFormat);
          try
               line = (SourceDataLine) AudioSystem.getLine(info);
                 The line is there, but it is not yet ready to
                 receive audio data. We have to open the line.
               line.open(audioFormat);
          catch (LineUnavailableException e)
               e.printStackTrace();
               System.exit(1);
          catch (Exception e)
               e.printStackTrace();
               System.exit(1);
            Still not enough. The line now can receive data,
            but will not pass them on to the audio output device
            (which means to your sound card). This has to be
            activated.
          line.start();
            Ok, finally the line is prepared. Now comes the real
            job: we have to write data to the line. We do this
            in a loop. First, we read data from the
            AudioInputStream to a buffer. Then, we write from
            this buffer to the Line. This is done until the end
            of the file is reached, which is detected by a
            return value of -1 from the read method of the
            AudioInputStream.
          int     nBytesRead = 0;
          byte[]     abData = new byte[EXTERNAL_BUFFER_SIZE];
          while (nBytesRead != -1)
               try
                    nBytesRead = audioInputStream.read(abData, 0, abData.length);
               catch (IOException e)
                    e.printStackTrace();
               if (nBytesRead >= 0)
                    int     nBytesWritten = line.write(abData, 0, nBytesRead);
            Wait until all data are played.
            This is only necessary because of the bug noted below.
            (If we do not wait, we would interrupt the playback by
            prematurely closing the line and exiting the VM.)
            Thanks to Margie Fitch for bringing me on the right
            path to this solution.
          line.drain();
            All data are played. We can close the shop.
          line.close();
            There is a bug in the jdk1.3/1.4.
            It prevents correct termination of the VM.
            So we have to exit ourselves.
          System.exit(0);
     private static void printUsageAndExit()
          out("SimpleAudioPlayer: usage:");
          out("\tjava SimpleAudioPlayer <soundfile>");
          System.exit(1);
     private static void out(String strMessage)
          System.out.println(strMessage);
}

I didnot go thru the code you posted but I know that the following workstry {
        // From file
        AudioInputStream stream = AudioSystem.getAudioInputStream(new File("audiofile"));
        // From URL
        stream = AudioSystem.getAudioInputStream(new URL("http://hostname/audiofile"));
        // At present, ALAW and ULAW encodings must be converted
        // to PCM_SIGNED before it can be played
        AudioFormat format = stream.getFormat();
        if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
            format = new AudioFormat(
                    AudioFormat.Encoding.PCM_SIGNED,
                    format.getSampleRate(),
                    format.getSampleSizeInBits()*2,
                    format.getChannels(),
                    format.getFrameSize()*2,
                    format.getFrameRate(),
                    true);        // big endian
            stream = AudioSystem.getAudioInputStream(format, stream);
        // Create the clip
        DataLine.Info info = new DataLine.Info(
            Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
        Clip clip = (Clip) AudioSystem.getLine(info);
        // This method does not return until the audio file is completely loaded
        clip.open(stream);
        // Start playing
        clip.start();
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (LineUnavailableException e) {
    } catch (UnsupportedAudioFileException e) {
    }

Similar Messages

  • Question about Java's HttpServer: Threading? Backlog?

    Hello,
    I have two questions about Java's HttpServer (com.sun.net.httpserver). From the JavaDoc:
    >
    Management of threads can be done external to this object by providing a Executor object. If none is provided a default implementation is used.
    >
    How can I get information about the default implementation in 1.6.0_13? Do you know the behavior? From my observations, the default implementation uses no Threads, meaning every request is handled in the same Thread, this results in handling the requests to the HttpServer one after another.
    Is this right?
    The second question is about this, also from the JavaDoc:
    >
    When binding to an address and port number, the application can also specify an integer backlog parameter. This represents the maximum number of incoming TCP connections which the system will queue internally. [...]
    >
    When setting the backlog to -1, it uses the systems default backlog. How can I determine the systems default backlog? Can some lines of Java code reveal it (there is no getBeacklog() method)? Or is it up to the Operating System (we use Redhat Linux)?
    Thanks a lot for your help!
    Regards,
    Timo

    How can I determine the systems default backlog?You can't. There is no API for that even at the C level.
    Can some lines of Java code reveal itNo.
    Or is it up to the Operating System (we use Redhat Linux)?Yes. Linux provides a large default. It seems to be at least 50 on most platforms. This is not something you should be worrying about.

  • Three questions about Java and Ftp

    Hello, i've the following questions about Java and Ftp:
    1- .netrc file is in $HOME directory but i can't access to this directory from java code. The following line producesan Exception (directory doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");
    2- .netrc file must have the following permissions: -rw- --- --- but when i create the .netrc file the following permissions are on default: -rw- r-- r--, how can i change this permissions? (In java code, i can't use chmod.....)
    3- Are there any way to pass parameters to a .netrc file? If i get to do this i needn't change the permissions because i can't modify or create/destroy this file.
    Thanks in advanced!!!
    Kike

    1- .netrc file is in $HOME directory but i can't
    access to this directory from java code. The
    following line producesan Exception (directory
    doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");$HOME would have to be replaced by a shell, I don't
    think you can use it as part of a legal path.
    Instead, use System.getProperty("user.home");
    Ok, thanks
    2- .netrc file must have the followingpermissions:
    -rw- --- --- but when i create the .netrc file the
    following permissions are on default: -rw- r--r--,
    how can i change this permissions? (In java code,i
    can't use chmod.....)Yes, you can: Runtime.exec("chmod ...");
    I need to use estrictly the .netrc with -rw- --- --- permissions
    Yes, i can use Runtime.exec ("chmod ..."); but i don't like very much this solution because is a slow solution, am i right?
    3- Are there any way to pass parameters to a.netrc
    file? If i get to do this i needn't change the
    permissions because i can't modify orcreate/destroy
    this file.I don't think so. Why do you need the .netrc file in
    Java at all? Writing a GUI frontend?I want to use automatic ftp in a java program and FTP server, the files and path are not always the same, so i can:
    - modify .netrc (for me is the complex option)
    - destroy and create a new .netrc (is easier but i have permissions problem)
    - use .netrc with parameters but i haven't found any help about it
    Thanks for your prompt reply!!!!
    Kike

  • Some questions about Java servlets

    I am having some problems with my Java servlets. Here they are below.
    #1 I have a login jsp page. When user logs in, the MySQL database is queried. If a match, redirect to appropriate page. The problem is I can't seem to remain in the login page if there is no match, I get a blank screen. If there is no match, how can I redirect it back to the login screen? For example, my login screen is login.jsp. Here is my code below.
    while(rs.next())
    if(rs != null)
    String name = rs.getString("USERNAME");
    Cookie getUser = new Cookie("User", name);
    response.addCookie(getUser);
    String sql2 = "INSERT INTO answers (USERNAME) VALUES( '" + name +"')";
    ResultSet rs2 = stmt.executeQuery(sql2);
    response.sendRedirect("profile410.jsp");
    out.println("<p>inside if structure");
    #2 After I go to the first screen after login, I am filling out a questionaire, and everytime I click on a submit button a different servlet comes into play, called InsertRecords.java. Everytime I go from one jsp to another, information gets stored into a database, InsertRecords.java is controlling this. I use the below code.
    String delete = request.getParameter("delete");
    String question = request.getParameter("question");
    String value = request.getParameter("R");
    if (delete.equals("no") && !value.equals(""))
    String sql = "INSERT INTO answers (" + question + ") VALUES (" + value + ")";
    int numRows = stmt.executeUpdate(sql);
    out.println("Record has been inserted");
    String nextPage = request.getParameter("nextPage");
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
    for (int i = 0; i < cookies.length; i++)
    String name = cookies.getName();
    String valuecook = cookies.getValue();
    Cookie getUser = new Cookie(name, valuecook);
    response.addCookie(getUser);
    response.sendRedirect(nextPage);
    the table is answer and the fields are ID, username, and q1, q2 q3, up to q11. the idea is upon login, the username gets stored into the answer table, the field username. I want the values stored in the same row everytime user jumps from one page to another based on his username. Goes to first jsp, q1 gets inserted, next jsp, q2 gets inserted, etc. But they all get inserted diagonally on different rows, not the same one, that is the problem. How can I fix this?
    #2 Based on the above code, say there is 11 jsp pages, remember, this is an online questionaire. When user logs in, he starts at the first jsp page, or question. When for example when the browser gets cut off at question6, when he logs back in, I want him to start at question4, if cut of at question 11, start again upon login at question 8. The reason, so he won't have to start from the beginning. Each question is on seperate jsp's. The way I see this happening is creating a session upon login and keeping that session. And grab 4th question when he logs back in, but I am not sure about how to go about it.
    Can someone help me please?

    Q1:
    Use the update command and not insert.
    Q2:
    Won't work. The user may log back in after the session has expired or from a different location. On log in look for a record for that user and what questions have been answered so far.

  • Question about java-based server app frameworks

    Hello, I am working on a Java applet application and would like to choose a Java-based scalable server framework to use within my applcation. I have found a few like xsocket or QuickServer and have a question about other. And, also, which is the one You may advise? Yours sincerely, Slawek

    For online gaming server. I first heard of xsocket and started using this, but have the problem with NAT. I now know that I need to initiate connections from client behind NAT (server has a public IP) and send messages from server to client within the same connection. I am doing this the following way (as shown in examples- below), but it appears that server receives messages, but client doesnt. I dont listen on any ports in client application and just need to take advantage of the connection initiated (information go from client to server properly).
    Server-
    try{ nbc = pool.getNonBlockingConnection(inetAddress, 8090);
    try{ nbc.write("|01|______|02|______|03|______|04|______|05|______|06|______|07|______|08|______|09|______|10|______"); }catch(Exception ee){}
    }catch(java.io.IOException f){}
    Client-
    public boolean onData(INonBlockingConnection nbc) throws IOException,ClosedChannelException,BufferUnderflowException,MaxReadSizeExceededException{
    String x = nbc.readStringByLength(100);
    System.out.println("S >> C = "+x);

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • Question about Java Errors

    I have some questions about some java errors
    1. what kind of errors are contained in Error class?
    2.does this class contain only runtime errors?
    3. if the question number 2 is positive, what about InstantiationError which is a compile error and is a subclass of Error.
    4.When our program is out of memory, which processes are done for an error to be produced. is the error actually from OS or VM?

    I have some questions about some java errors
    1. what kind of errors are contained in Error class?An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.
    2.does this class contain only runtime errors?No
    3. if the question number 2 is positive, what about
    InstantiationError which is a compile error and is a
    subclass of Error.
    4.When our program is out of memory, which processes
    are done for an error to be produced. is the error
    actually from OS or VM?Various - both, depending on where the error occurred.

  • Question about Java apps structure

    Hello guys,
    I'm a professional C++ programmer and I would like to start learning Java. I'm reading about Java from here and there and would like to ask you about how a java program is structured compared to C++.
    So in C++, I have main.cpp (or any other file name, doesn't matter), which contains a the main() function, and I have .h and .cpp class files that I instantiate (basically) in my main function to get my program to work.
    In Java, I'm confused and can't really find the "general" rule to how stuff are organised. I noticed that every class has a main function (why?), and there's no global scope. And "somehow", file names must exactly be equal to the class names.
    The question is: how are Java files of classes (and other stuff, if available) are arranged to create a program? What's the standard why? And How can I have many classes together in a single main()?
    Thank you for any efforts :-)
    Edited by: 927494 on 13.04.2012 07:02
    Edited by: 927494 on 13.04.2012 09:10

    Thank you guys for the replies. I still have some more doubts :-)
    Do I have to have a file for the implementation and a file for the definitons, like cpp and header files? or just everything inside the class?
    Why does Netbeans fail to compile when I change the class name? what should I change with the class name in general to have it compile correctly? From what I understand till now, the top level class's name (the class with the main() function that's gonna be executed) has to be equal to the file name (and I got that this is the sufficient condition for the app to compile), while the same file can have more classes if I wish. Did I get that right?
    I don't know if I get that right too, we pass only a SINGLE class/file to the compiler, and it automatically resolves ALLLL the included files automatically, unlike C++, where all cpp files have to be passed to the compiler/makefile to create object files, and then the executable is created after linking all those object files with the libraries together. i.e.: Java doesn't really need a makefile because making is really simple with only 1 filename. True?

  • Some questions about Java deployment steps and techniques

    All my java experience is coding and testing in my local machine (where, of course, a jre is available), but ... when I deploy to other people, they may not have a jre or they may have a different version of it than the one needed to run my application. I've read different stuff online including jars and java web start but still I have many questions.
    (1) first one first, Sun contradicts common sense, when it says that i can redistribute my own customized light version of their jre by taking out some files (java.sun.com/j2se/1.5.0/jre/README). there are two ways for me to get a jre: Way one is by downloading one from Sun, the download comes as an *.exe file and I don't see how I can take files out of it, so do you know how?. Way two would be by simply copying the set of files i choose (according to that Readme) from my current jre installation (the one on my \java\jdk\jre directory), does this make sense?, (if you're under windows) doesn't an installed version of a jre need a couple of dlls plus some new registry entries?, this contradicts common sense, if I'm not wrong, that Readme is a nonsense, but since that readme is at each of us jre installation \java\jdk1.x\jre\Readme, it can't be a nonsense, therefore I'm wrong, therefore the answer is either Way 1 or Way 2, HOW? ... or maybe there's a Way 3?
    (2) Say I never read that Readme so I download the jre (as an exe) to bundle it along with my application in a jar ... now I'll give my neighbor either a jar with two exes or two exes jars ... is there a way to make a jar so that two files get executed? ... if the answer is No and I have competition from a second neighbor, then I believe I'm asking my first neighbor to choose my application based on our friendship, that's not reasonable if we are doing business, so Java loses.
    (3) Say that my application is a single executable file like this,
    class X{
    public static void main(String[]$$$){
    System.out.println("Console, where are you?");
    At this point, say that my neighbor accepted the two executables, he executed the jre.exe and has jre6 in his system, now he double clicks on my X.jar ... it's a console application and jar files are not associated with the java.exe launcher since java 5, but with javaw which doesn't open any console ... how do i make it so a console opens and prints "Console, where are you?" ... do I ask my neighbor-customer to add a couple of lines to his path and open his console and (please) enter java -jar jarfile.jar? ... isn't it too much? ... i hope i'm wrong cause this is kind of discouraging
    (4) I've read that by installing a more recent version of a jre on a system that has an older jre (there to help other applications work), I might be causing a problem for the other applications to run ... I guess that's the reason why that Readme kind of encourage to redistribute a "private" version of a jre (one that doesn't come with a java.exe launcher ... any feedback on this?
    (5) I'm reading a lot of hype about Java Web Start ... it looks better than the traditional jar/jre deployment ... but setting up a MIME type to *.jnlp, it doesn't come with some free hosting I've checked ... somebody can recommend a free hosting service that allows to set a *.jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... and, anyhow, how you people compare it with the paradigm of the single executable file?.
    Thanks. Your feedback is highly appreciated.

    jorgelbanda wrote:
    ..(5) I'm reading a lot of hype about Java Web Start ... It's gratifying to think that someone who wants to deploy apps., has the common sense to search first! You would not guess how I often I hear "I wanna' make an EXE" shortly followed by "What's webstart?".
    ...it looks better than the traditional jar/jre deployment ... but setting up a MIME type to .jnlp, it doesn't come with some free hosting I've checked ... OK. You cannot define new mime types, but perhaps the site already has it defined. An easy way to check is to upload 'any old file' that ends in .jnlp and use the [mime type checker|http://pscode.org/mime/] to see what content type it is served as.
    ..somebody can recommend a free hosting service that allows to set a .jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... I'm pretty sure the Google based sites offer it.
    Note that I edited the asterisks out of your post, to avoid the forum software parsing half the reply as bold.

  • Question about Java implementation in Linux platform

    Hello,
    I shall implement one Java program in Linux platform. I'm a newer to linux. Need I install some special software in Linux platform to compile and run JAVA program?
    Thank you in advance
    java_linux

    Sorry, this forum is about Sun Studio, which is a collection of native compilers and tools. About Java, please use Java forum; for example, one of these: http://forums.sun.com/category.jspa?categoryID=5

  • Basic Java Sound Example.

    Hi,
    Can some one give me a basic java sound application( not applet ) to play a wav file.
    Thanks a lot.
    zia

    I did this search
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Bplay+%2Bsound+%2Bwav+%2Bapplication&col=jdc&x=14&y=10
    looks like the answer should be there somewhere

  • Question about my sound, please see these video examples

    Hi Premiere Elements gurus
    Say, I wonder if you know what's going on with my audio? If you look at these three clips:
    http://youtu.be/UkWyqPcULEM
    http://youtu.be/eXCs1W5DMx
    http://youtu.be/XsxvoieBnQA
    You'll notice that there is a lot of hiss in the background. In fact,  there used to be a little bit more, but I used the noise reducer in  Adobe Premiere Elements, but that make the audio sound a little weird,  with some extra reverb.
    Does it sound like there is more/extra hiss or room noise than you would  expect (than "normal")? And if so, if this caused by my equipment  setup, as I have a Sennhesier G2 Evolution wireless mic feeding into a  Canon Vixia via it's mini-plug, but I have the output on the Sennheiser  set very low and perhaps the Canon is adding extra gain to boost the  sound? Just a theory.
    Do you think it's possible to get clean sound, where I can remove the hiss/hum and just get vocal, using the audio effects? What plugins would I use and how would I use them, what settings?
    OR is there a third party audio scrubber that will clean the sound for me somewhere?
    Thanks!
    Ronald

    Hi both of you. Thanks for your replies!
    I think I found a solution. First, I've also uploaded a copy of two of the videos with the original sound and with the Noise Reduction effect removed, but the Denoiser (which was already in Premiere Elements since version 7) effect applied. The Denoiser did an excellent job of removing the extra noise that I hear.
    Do you guys hear a different in the audio between these sets of three clips?
    Kathy
    With Noise Reduction Effort (bad) http://www.youtube.com/watch?v=XsxvoieBnQA
    Original Soud http://www.youtube.com/watch?v=5sSzJ4mpg8Q
    With Denoiser Effect (good) http://www.youtube.com/watch?v=IA5pORnR_Bw
    Jaeny
    With Noise Reduction Effort (bad) http://www.youtube.com/watch?v=XsxvoieBnQAhttp://www.youtube.com/watch?v=UkWyqPcULEM
    Original Soud http://www.youtube.com/watch?v=6twTOnxFYhM
    With Denoiser Effect (good) http://www.youtube.com/watch?v=OIepnSlc3IY
    I think I'm happy with the Denoiser effect cleanup. Whew! I'm still going to reset the baseline levels of both my Sennheiser transmitter and receiver to see if I can get cleaner sound from them into the camera.
    PS: Thanks for the link and the suggestion to try the Magix software Bill, I am curious to get that.
    PPS: Thanks for your reply as well Steve. I now own three of your books (well, technically 2, as Muvipix.com Guide to Photoshop Elements & Premiere Elements 9 is two in one - still reading the photoshop part).
    Best,
    Ronald

  • Question about Java Applet Jar file signing.

    These questions pertain to Java 6 Standard Edition 1.6.0_22-b04 and later.
    I have gone through the Oracle Java Tutorial for generate public and private key information
    to sign a jar file, and how to sign the jar itself, all at
    [http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html]
    , and seek some clarification on the following related questions:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?
    -using the policytool policy file generator, what do I need to add under "Principals"
    (if anything) when dealing with a Java applet? Are Codebase and SignedBy simply author information?
    -If I choose to use a java.security.Permission subclass object set up in equivalent fashion within the Applet,
    which class within the Applet jar do I instantiate that object in? Does it need to be mentioned
    in the applet's jar Manifest.MF file?
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?
    -With this being the case, can the applet now escape
    the sandbox, be it with or without the stipulated
    policy permissions?

    848439 wrote:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?Just sign the applet, the policy file is not necessary.
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?No.
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).No. For a signed Jar, all the information is contained inside the Jar.
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?No. It is the JVM that determines when to pop the confirmation dialog.
    -With this being the case, can the applet now escape
    the sandbox, ..Assuming the end-user OK's the trust prompt, yes.
    ..be it with or without the stipulated
    policy permissions?Huh?

  • Question about Java MySQL connection

    Hi guys, greetings to y'all, me name is Ryan, I'm new 'round here.
    I have some questions, I have some application that I build with Java and using MSSQL Server 2000 as it's database, and now I want to try to use MySQL as it's database. I use MySQL server 5.0 and Navicat 8 for MySQL for the gateway and Win XP SP2 as my OS, what I want to know is, can you guys give me some connection string example for MySQL, for Java that is, I'm still learning in Java so sorry if I have some mistaken languages or code related words. Thanks a lot guys.
    Best Regards.

    Hi zahid, thanks for the reply, so if I have this code, like this one
    try
                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                  Connection con;
                                  con=DriverManager.getConnection("jdbc:odbc:FlightSource","","");
                                  stat2=con.prepareStatement("insert into Passenger_Table(vPassenger_Name,vPassenger_gender,iPassenger_Age,vPassenger_Destination,vPass_FlightClass,vPass_FlightType,vDate_of_Issue,vDate_of_Departure,vDate_Expire,vForm_Payment,Card_No,vTotal_Price)values(?,?,?,?,?,?,?,?,?,?,?,?)");
                                  stat2.setString(1,textNama.getText());
                                  stat2.setString(2,(String.valueOf(entry2)));
                                  stat2.setString(3,textUmur.getText());
                                  stat2.setString(4,textTujuan.getText());
                                  stat2.setString(5,(String)comboKelas.getSelectedItem());
                                  stat2.setString(6,(String)comboJenisKeberangkatan.getSelectedItem());
                                  stat2.setString(7,(String)comboTglTiket.getSelectedItem()+"/"+texttgltiket1.getText()+"/"+texttgltiket2.getText());
                                  stat2.setString(8,(String)comboTglBerangkat.getSelectedItem()+"/"+texttglberangkat1.getText()+"/"+texttglberangkat2.getText());
                                  stat2.setString(9,(String)comboTglKadaluwarsa.getSelectedItem()+"/"+texttglkadaluwarsa1.getText()+"/"+texttglkadaluwarsa2.getText());
                                  stat2.setString(10,(String)comboPayType.getSelectedItem());
                                  stat2.setString(11,textCardNo.getText());
                                  //stat2.setFloat(12,Float.parseFloat(textHarga.getText()));
                                  stat2.setString(12,textHarga.getText());
                                  stat2.executeUpdate();
                                  JOptionPane.showMessageDialog(null, "The Data has successfully Booked " );
                             catch(Exception exception)
                                  JOptionPane.showMessageDialog(null,"Error encountered while entering data in the database: "+exception);
                             }I just simply change the Class.forName{} line right ?
    What About the database name, considering in the code above I used ODBC (the ODBC name is FlightSource), so the database was configured when I create the ODBC, then how about MySQL, should I create ODBC too to configured the database that I wanna use ?

  • Some basic questions about Java ME

    Hi,
    I am new in the world of Java ME, I started to read about the technologies around it and for this reason I have some questions.
    There are 2 platforms CDC and CLDC and on top of these platforms there are some profiles, for example Personal Profile for CDC or MIDP2 for CLDC. On the next level (on top of these profiles) are some JSRs which are treated as optional packages.
    I saw that the CLDC emulator from SUN - WTK contains for example JSR 179 for Location based services and JSR 226 - SVG rendering. But the counterpart for CDC doesn't contain them.
    How can these JSRs be added to the CDC stack? are there some implementations of these JSRs as jars or something like this? or on the JCP site are only the specifications of this JSRs and if someone wants to add these JSRs to an emulator (virtual machine) he should implement these specifications?
    I hope that I have explained properly my "puzzle" and that someone will answer to my questions.
    Thank you

    1.    String[] numString = {"1","2","345678","9","abc"};
        int[] numInt = new int[numString.length];
        for (int x=0; x<numString.length; x++) {
          try {
         numInt[x] = Integer.parseInt(numString[x]);
          } catch (NumberFormatException nfe) {
         System.out.println(nfe.getMessage());
            numInt[x] = Integer.MIN_VALUE;
        }2. Best for what?

Maybe you are looking for