Encoding in Java XSU internationalisation problem

I have SUN Solaris 2.7, JDK 1.2, Oracle 8.0.5, Oracle XSU 1.2. When I use KOI8-R text encoding and set this in XSU then I see only signs "?????", but if I set ISO-8859-1 then it's Ok. I could work with ISO-8859-1, but in Oracle it stores bad text. Only latinian words was stored successful.

A new user name?
I can think of ways round your problem but can you first provide a reference that indicates that byte 0x80 is the MS936 encoding for the Euro?
P.S. This is a forum and the vast majority of participants, including me, have no direct relationship with Oracle so getting definitive answers from Oracle via this forum is unlikely. If you think you have found a bug in 1.5 and/or 1.6, and I am not convinced you have, you need to report it via the bug database. If it is a bug then the response time for a fix is likely to be months rather than days.
P.P.S No I can't explain why it works in 1.7!

Similar Messages

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Re   Java Stored Procedure Problem

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

    Ben
    There appear to be some problem with the forum. It doesn't want to show my response to your post with the subject "Java Stored Procedure Problem". See the answer to this thread for an example of how to do this...
    Is there a SAX parser with PL/SQL??

  • "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7"

    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    Periodically an application running in the Enterprise Java Engine
    (EJE) formerly known as the "Oracle 8i JVM", "the JSERVER component", or
    the "Aurora JVM" will fail with a "java 2" permissions error having the
    following format :
    Note : Message shown below have been reformatted for easier readability.
    java.sql.SQLException: ORA-29532: Java call terminated by uncaught Java exception:
    usually followed by a detailed error message similar to one of the following
    messages :
    Example # 1
    java.security.AccessControlException: the Permission
    (java.net.SocketPermission hostname resolve)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 2
    java.security.AccessControlException: the Permission
    (java.util.PropertyPermission * read,write)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Example # 3
    java.security.AccessControlException: the Permission
    (java.io.FilePermission \matt1.gif read)
    has not been granted by dbms_java.grant_permission to
    SchemaProtectionDomain(SCOTT|PolicyTableProxy(SCOTT))
    Explanation
    The java 2 permission stated in line # 2 of each of the above "Examples"
    has not been granted to the user specified in line 4 of the above "Examples".
    Solution Description
    The methodology to solve this issue is identical for all java 2 permissions
    cases.
    1) Format a call "dbms_java.grant_permission" procedure as described below.
    2) Logon as SYS or SYSTEM
    3) Issue the TWO commands shown below
    4) Logoff as SYS or SYSTEM
    5) Retry your application
    For Example # 1
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.net.SocketPermission',
    'hostname',
    'resolve');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 2
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.util.PropertyPermission',
    'read,write');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    For Example # 3
    1) Logon as SYS or SYSTEM
    2) Issue the following commands :
    a) call dbms_java.grant_permission('SCOTT',
    'java.io.FilePermission',
    '\matt1.gif',
    'read');
    b) commit;
    Note: Commit is mandatory !!
    3) Logoff as SYS or SYSTEM
    4) Retry your application
    References
    For more details on java 2 permissions and security within the EJE, review
    Chapter 5, in the Java Developer's Guide. entitled,
    "Security For Oracle8i Java Applications"
    The RDBMS 8.1.7 version can be found at :
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/index.htm

    Hi, Don,
    I solved the problem of security exception I mentioned at java procedure topic as following:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.SecurityException
    I tried to use your solution as following:
    call dbms_java.grant_permission('SDE', 'java.net.SocketPermission', 'ORCL.COHPA.UCF.EDU','resolve');
    but SQL*plus gave me a error message:
    invalid collumn.
    What's the problem?
    However, I call a grant command as following:
    SQL> grant JAVASYSPRIV to sde;
    and then that exception is gone. What's the difference between dbms_java.grant_permission and grant command?
    Thanks
    Bing
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by don -- oracle support:
    I'm in the process of publishing the following note (134280.1), titled "How to Resolve ORA-29532 Java 2
    Permission Problems in RDBMS 8.1.6 and 8.1.7".
    It will be accessible from Oracle Support's "Metalink" site.
    "How to Resolve ORA-29532 Java 2 Permission Problems in RDBMS 8.1.6 and 8.1.7".
    Problem Description
    <HR></BLOCKQUOTE>
    null

  • Finding a Gif Encoder for Java Advanced Imaging (JAI)

    I'm trying to find the GIF encoder for Java Advanced Imaging. I keep reading all over the place that there is one, but for the life of me I can't figure out where it is supposed to be. Could anyone please enlighten me?
    Thanks

    After I installed this, it still doesn't report gif as a possible encoding type:
    String[] codecs = ImageCodec.getEncoderNames(img, null);
                for (int j = 0; j < codecs.length; j++) {
                    String codec = codecs[j];
                    System.out.println (codec);
                }only reports the following types available:
    pnm
    jpeg
    tiff
    png
    bmp

  • Output encoding in Java mapping ?

    Hello,
    I have written a Java mapping which reads an input document and creates an output document. My problem is, the German special characters are lost in the output document (wrong characters). This is strange, because I am only using regular DOM methods for adding the output nodes and values. Anybody has an idea where I have to explicitly define the output encoding ? XI automatically uses UTF-8, I am using the StandardDOMWriter class of the com.inqmy.lib.xml package from XI, and DocumentBuilder from javax.xml.parsers.
    But the output is wrong nevertheless. I think the encoding is already set in the OutputStream input variable of the execute methods. So no need to be changed (?)
    Code sample below:
    public void execute(InputStream in, OutputStream out)  throws StreamTransformationException {
           DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
           DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
           Document idoc = documentBuilder.parse(in);   // input document           
           Document odoc = documentBuilder.newDocument();     // output document
           // create some elements and values with helper method below
          // write output document to stream
          odoc.appendChild(oRoot);
          StandardDOMWriter sdw = new StandardDOMWriter();
          sdw.write(odoc, out, null);               
        private Element createElement(String elementName, String value, Element parent, Document doc) {   
          Element element = createElement(elementName, parent, doc);
          // here we put the input content to output value
          element.appendChild(doc.createTextNode(value));     
          // ok, special character still there:
           trace.addInfo("Read back: " + getNodeValue(element));
          return element;
    CSY

    I solved the problem. For some reason, the inqmy parser does not work correctly. If I remember correctly, the SapXMLToolkit (from where it comes), is deprecated anyway.
    Instead I use now standard JAXP transform streaming, and that works fine:
          // commented code does not convert german special characters correctly:
          //StandardDOMWriter sdw = new StandardDOMWriter();     
          //sdw.write(odoc, out, null);
         // Serialisation through Transform.
         DOMSource domSource = new DOMSource(odoc);
         StreamResult streamResult = new StreamResult(out);
         TransformerFactory tf = TransformerFactory.newInstance();
         Transformer serializer = tf.newTransformer();
         serializer.setOutputProperty(OutputKeys.ENCODING,"UTF-8");    
         serializer.setOutputProperty(OutputKeys.INDENT,"yes");
         serializer.transform(domSource, streamResult);                            
    CSY

  • Get canvas.toDataURL('image/jpeg') and convert base64 encoding to java.sql.Blob

    Convert canvas.toDataURL('image/jpeg') to java.sql.Blob.
    I am using oracle adf so I am able to action a backing bean from javascript and pass in parameters as a map. I pass in the canvas.toDataURL('image/jpeg') which I then try to decode in my bean. Using BASE64Decoder and the converting the bytearray to a file I can see the image is corrupted as I can't open the file thus converting the bytearray to blob is also a waste.
    Has anyone any ideas on base64 encoding from canvas.toDataURL to file or Blob?

    Use Case:
    A jsf page that enables a user to take photos using the HTML5 canvas feature - interact with webcam -, take photos and upload to profile
    1. I have created the jsf page with the javascript below; this pops up as a dialog and works okay and onclick an upload image, triggers the snapImage javascript function below and sends the imgURL parameter to the serverside managedbean
    <!-- java script-->
    function snapImage(event){
                    var canvas = AdfPage.PAGE.findComponent('canvas');
                    AdfCustomEvent.queue(event.getSource(),"getCamImage",{imgURL:canvas.toDataURL('image/jpeg'),true);
                    event.cancel();
    <!-- bean -->
    public void getCamImage(ClientEvent ce){
    String url=(String)ce.getAttributes().get("imgURL");
    decodeBase64URLToBlob(url);
    private BlobDomain decodeBaseB4URLToBlob(String url64){
                    BASE64Decoder de=new BASE64Decoder();
                    byte[] bytes=de.decode(url64);
                    File file=new File("abc.jpg");
                    InputStream in = new ByteArrayInputStream(bytes);
                    BufferedImage bImageFromConvert = ImageIO.read(in);
                    in.close();
                    ImageIO.write(bImageFromConvert, "jpg", file);
                    return createBlobDomainFromFile(file);
    ----problem---
    Accessing the generated jpeg file shows the image is corrupted, probably missing bytes or encode/decoder issues.and the blob image after uploading to database is saved as a binary stream which ondownload doesnt render as an image or anything i know of.
    Is there anyways of achieving the conversion without errors?

  • Jre 1.4.2_12 + java excel api problem.

    I got problem when i write a program to read chinese excel sheet with jre 1.4.2_12, chinese will encoding incorrect in java, but when I change jre version to jre 1.4.2_10 or jre 1.5.0 update 7 , everything s ok . any solution?
    p.s. jexcelapi 2.5.8

    I got problem when i write a program to read chinese
    excel sheet with jre 1.4.2_12, chinese will encoding
    incorrect in java, but when I change jre version to
    jre 1.4.2_10 or jre 1.5.0 update 7 , everything s ok
    . any solution?
    p.s. jexcelapi 2.5.8Hi Vencent,
    I am also seeing encoding problems with 1.4.2_12 and havent been able to find a solution. Did you find a solution to your problem? If so I'd appreciate it if you could post it.
    Thanks,
    Declan.

  • Not exactly a Java.Sound.* problem...

    Hello folks! I am writing a piece of code that takes a .wav file, encoded with 16 bits/sample, and has to perform a "thersholding" operation in these samples. That is, that groups of samples that don't have enough mean energy, shall not be included in the new .wav file that will contain the thresholded sample (the whole process is a short of compression).
    The problem is, that for some reason I haven't discovered yet, only half of the bytes of the original file are found in the final file! (But, the thresholding mechanism works well in these half samples :P)
    Could you please check on my code? 15 javies for the one who gives me a solution! :)
    Here goes my code
    // 16bits/sample
    // line 47 -> input .wav file
    import java.io.*;
    import javax.sound.sampled.*;
    public class thresholding16 {
    public thresholding16() {
    try {
    jbInit();
    } catch (Exception ex) {
    ex.printStackTrace();
    AudioFormat audioFormat;
    AudioInputStream audioInputStream;
    //initial samples from File
    byte buffer[] = new byte[10000000];
    //thresholded samples ->to be written in a new File
    byte newBuffer[] = new byte[10000000];
    //the initial 2-byte samples will be represented as an integer (by merging the MSB,LSB of the sample)
    int intArray[]=new int[5000000];
    //mean energy of samples for every one of the 200000 groups of 25 samples
    double energyArray[] = new double[200000];
    public static void main(String args[]){
    try{
    thresholding16 thres=new thresholding16();
    thres.moveToBuffer();
    catch(Exception x){
    System.out.println(x);
    void moveToBuffer() {
    int cnt=0;
    try{
    File soundFile =
    new File("aFile0.wav"); //to arxeio eisodou pou 8a 'katwfliw8ei'
    audioInputStream = AudioSystem.
    getAudioInputStream(soundFile);
    audioFormat = audioInputStream.getFormat();
    System.out.println(audioFormat);
    for(int h=0;h<10000000;h++){
    buffer[h]=0;
    while((cnt = audioInputStream.read(buffer,0,buffer.length)) != -1){
    System.out.println("Ta arxika deigmata ws bytes");
    for(int j=0;j<10000;j++){
    System.out.println(j+" "+buffer[j]);
    FileWriter fistream = new FileWriter("16bitArxika.txt");
    BufferedWriter outi = new BufferedWriter(fistream);
    outi.write("Ta arxika deigmata ws bytes"+"\r\n");
    for(int j=0;j<10000;j++){
    outi.write(buffer[j]+"\r\n");
    //Close the output stream
    outi.close();
    //merge the 2 bytes of a sample int one integer
    for(int j=0;j<5000000;j++){
    int num=0;
    int msb=0;
    int lsb=0;
    msb=buffer[j*2+1];
    lsb=buffer[j*2];
    int h=buffer[j*2+1];
    if (h<0){
    num=msb&lsb;
    else{
    num=msb^lsb;
    intArray[j]=num;
    }//end for
    FileWriter fistream = new FileWriter("16bitArxika.txt");
    BufferedWriter outi = new BufferedWriter(fistream);
    outi.write("Ta arxika deigmata ws bytes"+"\r\n");
    for(int j=0;j<200000;j++){
    outi.write(intArray[j]+" ");
    //Close the output stream
    outi.close();
    System.out.println("Ena deigma -> enas integer");
    for(int j=0;j<500;j++){
    System.out.println(j+" "+intArray[j]);
    for(int i=0;i<200000;i++){
    energyArray=0;
    //Mean energy estimated from the type //&#917;=10log(&#949;+1/&#925;&#931;S^2(n))
    for(int i=0;i<200000;i++){
    for(int j=0;j<25;j++){
    energyArray[i]=energyArray[i]+intArray[i*25+j]*intArray[i*25+j];
    // System.out.println("Mesh Energeia ana omada");
    for(int i=0;i<200000;i++){
    double h=0;
    h=Math.log(energyArray[i]/25+000000.1)/Math.log(10);
    energyArray[i]=h;
    //auxiliary array that tells which groups of bytes pass and //which do not
    int booleanArray[] = new int[200000];
    for(int j=0;j<200000;j++){
    booleanArray[j]=0;
    if (energyArray[j]>2.1){   //the wanted threshold
    booleanArray[j]=1;
    for(int i=0;i<10000000;i++){
    newBuffer[i]=buffer[i];
    //I put 0 to the proper positions, depending on whether the //groups of bytes has passed the thresholding operation
    for(int i=0;i<200000;i++){
    if(booleanArray[i]==0){
    for(int j=0;j<25;j++){
    newBuffer[i*25+j*2]=0; // 0 at MSB
    for(int j=1;j<26;j++){
    newBuffer[i * 25 + j * 2 - 1] = 0; // 0 at LSB
    FileWriter fstream = new FileWriter("16bitDeigmataKatwfliwmena.txt");
    BufferedWriter out = new BufferedWriter(fstream);
    out.write("Ta telika deigmata ws bytes"+"\r\n");
    for(int j=0;j<10000000;j++){
    out.write(newBuffer[j]+"\r\n");
    //Close the output stream
    out.close();
    //the new .wav file
    ByteArrayInputStream bis=new ByteArrayInputStream(newBuffer);
    AudioInputStream ais=new AudioInputStream(bis,audioFormat,newBuffer.length/audioFormat.getFrameSize());
    int cnt2;
    cnt2 = audio system.write(ais,AudioFileFormat.Type.WAVE,new File("aFile0Thres.wav"));
    System.out.println(" "+cnt2);
    catch (Exception e) {
    }//end of method moveToBuffer
    private void jbInit() throws Exception {
    }//end of class thresholding16

    >
    How do i merge all the XSL's..... can i use something
    like a master XSL that calls the other 4 documenst
    one after the other.
    Something like <XSL:Import> or <XSL:Include>
    You can import other stylesheets and use the templates they contain. You can also import one or more stylesheets and then optionally redefine any templates that they define.
    <xsl:stylesheet      version="1.0"      
                                       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                       xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java">
         <!-- import the core functionality -->
         <xsl:import href="../common/generic_csv.xslt"/>
    Some other templating code...
    </xsl:stylesheet>Is this what you are after?

  • XSU Insert Problem with ORA-00001

    Hi,
    I am writing an application which will extract a series of tables from a source database and then populate a target database.
    I am using the XSU utility to extract each table individually into its own physical XML file.
    The extraction goes well, but on some tables the population has a problem.
    During the population process, the OracleXMLSave utility throws an exception:
    Error in loadFile oracle.xml.sql.OracleXMLSQLException: Exception 'java.sql.SQLException:ORA-00001: unique constraint (MYDB.SYS_C001346) violated encountered during processing ROW element 97All prior XML row changes were rolled back. in the XML document.
    I know for a fact that there is no duplicate primary key entries in the physical xml file.
    I am using the XSU - XSU12_ver2_1_0_beta with JDBC2.0 (JDK1.3 and loadable into Oracle8.1.7
    Has anyone seen this?
    I am at a critical point in the project. Any help appreciated.
    Mario Andreoli
    ComponenTech.com
    [email protected]

    Hi,
    I am writing an application which will extract a series of tables from a source database and then populate a target database.
    I am using the XSU utility to extract each table individually into its own physical XML file.
    The extraction goes well, but on some tables the population has a problem.
    During the population process, the OracleXMLSave utility throws an exception:
    Error in loadFile oracle.xml.sql.OracleXMLSQLException: Exception 'java.sql.SQLException:ORA-00001: unique constraint (MYDB.SYS_C001346) violated encountered during processing ROW element 97All prior XML row changes were rolled back. in the XML document.
    I know for a fact that there is no duplicate primary key entries in the physical xml file.
    I am using the XSU - XSU12_ver2_1_0_beta with JDBC2.0 (JDK1.3 and loadable into Oracle8.1.7
    Has anyone seen this?
    I am at a critical point in the project. Any help appreciated.
    Mario Andreoli
    ComponenTech.com
    [email protected]

  • Video\Audio encoding in Java

    Hi,
    I need to write an application that will convert videos to different formats. Like: mov to mp4, flv to mp4, etc
    Anybody know of java classes\libraries I could use to implement this?
    Thanks!
    Tamara

    scottjsn wrote:
    How can I in the java class DYNAMICALLY set up the encoding so that the sysytem at the runtime will acccept the Cyrillic characters. Nonsensical. Java strings are unicode. Always. If you have a java string and you pass it to a java method it remains a java string.
    And the Cyrillic characters are mapped into unicode. So a java string can certainly contain them.
    Your problem probably lies either in getting Cyrillic into the string or setting up the "display" so it get displayed.
    You first step should be in understanding that there is a difference between data (such as what is in a string) and display (what you see on a screen.) Data is always mapped when displayed. Understanding how that mapping occurs is important.

  • Byte pair Encoding in java

    I have downloaded the code related to Byte Pair encoding. It is
    specific to C and C++ languages. I tried porting the code from c to Java, but i have faced problem with the length available in C & java for character. In java it takes 2 bytes but in C it is one. I have
    been trying to get the working code for Java. But till now i didn't get the proper one. Please help me. link has given below.
    http://www.csse.monash.edu.au/cluster/RJK/Compress/problem.html
    http://www.csse.monash.edu.au/cluster/RJK/Compress/bpe.c (for
    byte pair encoding example code in c)
    if any body have a example code for Byte Pair Encoding,pls give the link
    Thanks and Regards,
    B.Rajesh

    1. The Java type byte is probably what you want to use for the C type char.
    2. I think the following paragraph is incorrect:
    LZW compression adapts linearly to frequently occurring patterns, building up strings one character at a time. The BPE algorithm adapts exponentially to patterns, since both bytes in a pair can represent previously defined pair codes. The previously defined pair codes can themselves contain nested codes and can expand into long strings.
    I don't know the details of LZW, but my understanding of the LZ family is that they also have exponential adaption for the same reason as BPE. The primary difference, ISTM, is that LZ increases the size of the tokens beyond a byte.

  • Jpeg encoding with imageio - pink distortion problem

    Hello, I am using the imageio classes to scale down jpg images (for thumbnails) and write them to a file. On most images, everything works perfectly. On some images, however, the resulting thumbnail image has a strange pink coloration to the whole picture. Does anyone have any ideas as to why this would happen? The code I am using is below. I thank anyone that takes the time to read this and hope someone can help.
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.image.AffineTransformOp;
    import java.awt.image.BufferedImage;
    import java.awt.image.IndexColorModel;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.imageio.IIOImage;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageTypeSpecifier;
    import javax.imageio.ImageWriteParam;
    import javax.imageio.ImageWriter;
    import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
    import javax.imageio.stream.ImageOutputStream;
    public class ImageResizer
         private static final int THUMBNAIL_MAX = 120;
         private static final int SMALL_MAX = 250;
         private static final int LARGE_MAX = 575;
         private static final int LARGE_THRESHOLD = 425;
         BufferedImage inImage;
         int width;
         int height;
         private static JPEGImageWriteParam params;
         static {
              JPEGImageWriteParam params = new JPEGImageWriteParam(null);
              params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
              params.setCompressionQuality(0.8f);
              params.setProgressiveMode(ImageWriteParam.MODE_DISABLED);
              params.setDestinationType(
                   new ImageTypeSpecifier(IndexColorModel.getRGBdefault(),
                   IndexColorModel.getRGBdefault().createCompatibleSampleModel(16,16)));
         public ImageResizer(byte[] image, long id) throws IOException
              inImage = ImageIO.read(new ByteArrayInputStream(image));
              width = inImage.getWidth(null);
              height = inImage.getHeight(null);
         public void makeSmallImage (File outputFile) throws IOException {
              resizeImage(120, outputFile);
         private void resizeImage (int maxDim, File file) throws IOException {
              double scale = maxDim / (double) height;
              if (width > height) scale = maxDim / (double) width;
              int scaledWidth = (int)(scale * width);
              int scaledHeight = (int)(scale * height);
              BufferedImage outImage = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_RGB);
              AffineTransform xform = AffineTransform.getScaleInstance(scale, scale);
              AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
              // Paint image.
              Graphics2D g2d = outImage.createGraphics();
              g2d.drawImage(inImage, op, 0, 0);
              g2d.dispose();
              // write the image out
              ImageOutputStream ios = null;
              try {
                   ios = ImageIO.createImageOutputStream(file);
                   ImageWriter writer = (ImageWriter) ImageIO.getImageWritersByFormatName("jpg").next();
                   writer.setOutput(ios);
                   writer.write(null, new IIOImage(outImage, null, null), params);
                   writer.dispose();
              catch (IOException e) {
                   System.out.println("cought IOException while writing " +
                   file.getPath());
              finally {
                   if (null != ios) ios.close();
    }

    I am having the same problem with jpegs.
    The strange thing is that this only happends with the same exact code on OS X, while it never happens on any windows machine.
    I have tried using the the ImageIO classes, and a class I got off of this board a while back; however when using this class on an OS X machine, encoding takes a really long time and gives the pink distortion.
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.swing.*;
    import com.sun.image.codec.jpeg.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.geom.*;
    public class ImageUtils {
         private static JPEGImageEncoder encoder = null;
         private static FileOutputStream fileStream = null;
         public static BufferedImage createComponentImage(Component component)
              BufferedImage image = (BufferedImage)component.createImage(component.getWidth(),component.getHeight());
              Graphics graphics = image.getGraphics();
              if(graphics != null) { component.paintAll(graphics); }
              return image;
         public static void encodeImage(BufferedImage image, File file) throws IOException
              fileStream = new FileOutputStream(file);
              JPEGEncodeParam encodeParam = JPEGCodec.getDefaultJPEGEncodeParam(image);
              encoder = JPEGCodec.createJPEGEncoder(fileStream);
              encoder.encode(image,encodeParam);
    }use it like this:
    File file = new File("ImageTest.jpg");
    image = ImageUtils.createComponentImage(imageCanvas);
    ImageUtils.encodeImage(image,file);

  • Best Audio Encoder for Java???

    In my program, I can only play .au files in Java.. I have a few .wavs that I would like to incorporate into my program, but I need to change them into .au . Ive tried using COOL EDIT PRO 2 and SOUND FORGE 6.0 to open up the .wavs, then save them as .au .. I run my Java program, but an error comes up saying INVALID ENCODING and INVALID FILE TYPE.. Does anyone have a solution for this frustrating problem I have? It's very urgent and I need your help, thanks...

    It took me 4 clicks and 12 keystrokes to find this.
    http://java.sun.com/docs/books/tutorial/sound/problems.html
    I clicked Tutorials
    I clicked The Java Tutorial
    I clicked in the Tutorial Search textField
    I typed sound files <enter>
    The first one looked good to me, click!
    Live and learn,
    Radish21

  • SSO java sample application problem

    Hi all,
    I am trying to run the SSO java sample application, but am experiencing a problem:
    When I request the papp.jsp page I end up in an infinte loop, caught between papp.jsp and ssosignon.jsp.
    An earlier thread in this forum discussed the same problem, guessing that the cookie handling was the problem. This thread recommended a particlar servlet , ShowCookie, for inspecting the cookies for the current session.
    I have installed this cookie on the server, but don't see anything but one cookie, JSESSIONID.
    At present I am running the jsp sample app on a Tomcat server, while Oracle 9iAS with sso and portal is running on another machine on the LAN.
    The configuration of the SSO sample application is as follows:
    Cut from SSOEnablerJspBean.java:
    // Listener token for this partner application name
    private static String m_listenerToken = "wmli007251:8080";
    // Partner application session cookie name
    private static String m_cookieName = "SSO_PAPP_JSP_ID";
    // Partner application session domain
    private static String m_cookieDomain = "wmli007251:8080/";
    // Partner application session path scope
    private static String m_cookiePath = "/";
    // Host name of the database
    private static String m_dbHostName = "wmsi001370";
    // Port for database
    private static String m_dbPort = "1521";
    // Sehema name
    private static String m_dbSchemaName = "testpartnerapp";
    // Schema password
    private static String m_dbSchemaPasswd = "testpartnerapp";
    // Database SID name
    private static String m_dbSID = "IASDB.WMDATA.DK";
    // Requested URL (User requested page)
    private static String m_requestUrl = "http://wmli007251:8080/testsso/papp.jsp";
    // Cancel URL(Home page for this application which don't require authentication)
    private static String m_cancelUrl = "http://wmli007251:8080/testsso/fejl.html";
    Values specified in the Oracle Portal partner app administration page:
         ID: 1326
         Token: O87JOE971326
         Encryption key: 67854625C8B9BE96
         Logon-URL: http://wmsi001370:7777/pls/orasso/orasso.wwsso_app_admin.ls_login
         single signoff-URL: http://wmsi001370:7777/pls/orasso/orasso.wwsso_app_admin.ls_logout
         Name: testsso
         Start-URL: http://wmli007251:8080/testsso/
         Succes-URL: http://wmli007251:8080/testsso/ssosignon.jsp
         Log off-URL: http://wmli007251:8080/testsso/papplogoff.jsp
    Finally I have specified the cookie version to be v1.0 when running the regapp.sql script. Other parameters for this script are copied from the values specified above.
    Unfortunately the discussion in the earlier thread did not go any further but to recognize the cookieproblem, so I am now looking for help to move further on from here.
    Any ideas will be greatly appreciated!
    /Mads

    Pierre - When you work on the sample application, you should test the pages in a separate browser instance. Don't use the Run Page links from the Builder. The sample app has a different authentication scheme from that used in the development environment so it'll work better for you to use a separate development browser from the application testing browser. In the testing browser, to request the page you just modified, login to the application, then change the page ID in the URL. Then put some navigation controls into the application so you can run your page more easily by clicking links from other pages.
    Scott

Maybe you are looking for