I am not able to compile this program because it has an compile error.

Please identify the problem and offer and/or correct the problem.+_
Thank you very much for helping a new java wana_be programmer!+_
Below is the source code:+_
*===================*_
import java.awt.*;
import java.awt.MediaTracker;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.geom.GeneralPath;
import java.io.*;
import javax.swing.*;
import javax.imageio.*;
import java.net.URL;
public class JavaPicture{
public BufferedImage bimg;
public JFrame shower = new JFrame();
public ImageIcon imgIcon;
public Canvas canvas;
public Image image;
* Constructor
public void JavaPicture(){
//No picture, no values
public int getWidth(){
return bimg.getWidth();
public int getHeight(){
return bimg.getHeight();
* Load image
public boolean loadImage(String filename){
try{
/*bimg = null;
filename = "file://" + filename;
URL u = new URL(filename);
File f = new File(u.getPath());
bimg = ImageIO.read(f);
Toolkit toolkit = Toolkit.getDefaultToolkit();
               image = toolkit.getImage(filename);
               MediaTracker mediaTracker = new MediaTracker(shower);
               mediaTracker.addImage(image, 0);
               try
                    mediaTracker.waitForID(0);
               catch (InterruptedException ie)
                    //The file did not load
                    System.err.println(ie);
               bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), bimg.TYPE_INT_RGB);
               Graphics g = bimg.getGraphics();
               g.drawImage(image, 0, 0, null);
return true;
catch (Exception e) {return false;}
public void createNewImage(int width, int height){
     bimg = null;
     bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
public void repaintImage(){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.repaint();
public void showPictureWithTitle(String s){
if (shower.isVisible()){
imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.setTitle(s);
shower.repaint();
else {
shower = new JFrame(s);
imgIcon = new ImageIcon(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
shower.getContentPane().add(new JLabel(imgIcon));
shower.setResizable(false);
shower.pack();
shower.show();
* Saves the image represented by the JavaPicture object onto disk.
* @param newfilename the file name to save to
* @exception java.io.IOException raised if the save fails
public boolean saveImage(String newfilename) throws java.io.IOException
FileOutputStream out;
JPEGImageEncoder jpeg;
     File filen;
try {
     filen = new File(newfilename);
     //if (filen.canWrite()){
          //return false;}
out = new FileOutputStream(filen);
catch (Exception e){
System.out.println("Sorry -- that filename ("+newfilename+") isn't working");
return false;
try {
jpeg = JPEGCodec.createJPEGEncoder(out);
catch (Exception e) {
System.out.println("Unable to create a JPEG encoder");
return false;
JPEGEncodeParam param = jpeg.getDefaultJPEGEncodeParam(bimg);
param.setQuality(1.0f,true);
jpeg.encode(bimg,param);
out.close();
     return true;
* Returns the pixel value of a pixel in the picture, given its coordinates.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @return the pixel value as an integer
public int getBasicPixel(int x, int y)
// to access pixel at row 'j' and column 'i' from the upper-left corner of
// image.
return bimg.getRGB(x,y);
* Sets the value of a pixel in the picture.
* @param x the x coordinate of the pixel
* @param y the y coordinate of the pixel
* @param rgb the new rgb value of the pixel
public void setBasicPixel(int x, int y, int rgb)
bimg.setRGB(x,y,rgb);
* Returns a JavaPixel object representing a pixel in the picture given its coordinates
* @param x the x coordinates of the pixel
* @param y the y coordinates of the pixel
* @return a JavaPixel object representing the requested pixel
public JavaPixel getPixel(int x, int y)
return new JavaPixel(this,x,y);
* Test Main
*@param String[] argvs
     public static void main(String[] args)
          JavaPicture p = new JavaPicture();
          //p.createNewImage(100,100);
          //p.showPicture();
p.loadImage("D:\\public_html\\Apache2\\webroot\\webpage\\atlanta_skyline.jpg");
p.showPictureWithTitle("Test");
     }

Try this.
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
     public class JavaPicture{
     public BufferedImage bimg;
     public JFrame shower = new JFrame();
     public ImageIcon imgIcon;
     public Canvas canvas;
     public Image image;
     Constructor
     public void JavaPicture(){
     //No picture, no values
     public int getWidth(){
     return bimg.getWidth();
     public int getHeight(){
     return bimg.getHeight();
     Load image
     public boolean loadImage(String filename){
     try{
     bimg = null;
     filename = "file://"+ filename;
     URL u = new URL(filename);
     File f = new File(u.getPath());
     bimg = ImageIO.read(f);
     Toolkit toolkit = Toolkit.getDefaultToolkit();
     image = toolkit.getImage(filename);
     MediaTracker mediaTracker = new MediaTracker(shower);
     mediaTracker.addImage(image, 0);
     try
     mediaTracker.waitForID(0);
     catch (InterruptedException ie)
     //The file did not load
     System.err.println(ie);
     bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), bimg.TYPE_INT_RGB);
     Graphics g = bimg.getGraphics();
     g.drawImage(image, 0, 0, null);
     return true;
     catch (Exception e) {return false;}
     public void createNewImage(int width, int height){
     bimg = null;
     bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
     public void repaintImage(){
     if (shower.isVisible()){
     imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
     shower.repaint();
     public void showPictureWithTitle(String s){
     if (shower.isVisible()){
     imgIcon.setImage(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
     shower.setTitle(s);
     shower.repaint();
     else {
     shower = new JFrame(s);
     imgIcon = new ImageIcon(bimg.getScaledInstance(bimg.getWidth(), bimg.getHeight(), Image.SCALE_FAST));
     shower.getContentPane().add(new JLabel(imgIcon));
     shower.setResizable(false);
     shower.pack();
     shower.show();
     Saves the image represented by the JavaPicture object onto disk.
     @param newfilename the file name to save to
     @exception java.io.IOException raised if the save fails
     public boolean saveImage(String newfilename) throws java.io.IOException
     FileOutputStream out;
     JPEGImageEncoder jpeg;
     File filen;
     try {
     filen = new File(newfilename);
     //if (filen.canWrite()){
     //return false;}
     out = new FileOutputStream(filen);
     catch (Exception e){
     System.out.println("Sorry -- that filename ("+newfilename+") isn't working");
     return false;
     try {
     jpeg = JPEGCodec.createJPEGEncoder(out);
     catch (Exception e) {
     System.out.println("Unable to create a JPEG encoder");
     return false;
     JPEGEncodeParam param = jpeg.getDefaultJPEGEncodeParam(bimg);
     param.setQuality(1.0f,true);
     jpeg.encode(bimg,param);
     out.close();
     return true;
     Returns the pixel value of a pixel in the picture, given its coordinates.
     @param x the x coordinate of the pixel
     @param y the y coordinate of the pixel
     @return the pixel value as an integer
     public int getBasicPixel(int x, int y)
     // to access pixel at row 'j' and column 'i' from the upper-left corner of
     // image.
     return bimg.getRGB(x,y);
     Sets the value of a pixel in the picture.
     @param x the x coordinate of the pixel
     @param y the y coordinate of the pixel
     @param rgb the new rgb value of the pixel
     public void setBasicPixel(int x, int y, int rgb)
     bimg.setRGB(x,y,rgb);
     Returns a JavaPixel object representing a pixel in the picture given its coordinates
     @param x the x coordinates of the pixel
     @param y the y coordinates of the pixel
     @return a JavaPixel object representing the requested pixel
     public JavaPixel getPixel(int x, int y)
     return new JavaPixel(this,x,y);
     Test Main
     @param String[] argvs
     public static void main(String[] args)
     JavaPicture p = new JavaPicture();
     //p.createNewImage(100,100);
     //p.showPicture();
     p.loadImage("D:\\public_html\\Apache2\\webroot\\webpage\\atlanta_skyline.jpg");
     p.showPictureWithTitle("Test");
     } Rasa

Similar Messages

  • I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    See this -> http://support.apple.com/kb/TS1299

  • Safari is not able to open this page because it can not find the server.

    I too need help with this problem with my Ipod touch. Currently, I am in the Ukraine, go to a wifi cafe, access the wifi and get a clear powerful signal. Then I try to load the Google page, any page from my bookmark or write the web address in and I receive the same message; "Safari can not open this page because it can not find the server." Something is wrong with my settings and I tried to reset the options but it does not work. Can anyone help me with this problem? Thanks!!

    Hello and Welcome to Apple Discussions. 
    The 169.254.xxx.xxx address indicates that there is a problem with DHCP server in your BT Digital Hub (Home hub?) because the iPod is taking a default IP rather than been given a suitable one. At the moment the iPod is not even in the same subnet as the router so it's no wonder that Safari can't find the Internet.
    Ensure that the DHCP server is on and that you have an IP-address pool sufficiently large to serve all the devices you have. I'd expect it to be 192.168.1.1 to 192.168.1.253. If you have FON enabled you certainly need that wider range as other people may be using your router too.
    mrtotes

  • Why am i not able to run this program ??

    When i exec a single process it works fine but when i try to execute array of commands i couldn't it complies but doesn't execute any 1 of the commands.
    Please let me know
    import java.io.IOException;
    class RunTime
    public static void main(String raja[])
    Runtime r = Runtime.getRuntime();
    Process p;
    String[] commands = { "notepad","calcic","mspaint"};
    System.out.println("Executing processes please wait........");
    try
    int commandslength = commands.length;
    for(int i = 0 ; i < commandslength ; i++)
    p = r.exec("commands");
    catch(Exception e)     
    System.out.println("Cant proceed furthur ..");

    Instead ofp = r.exec("commands");dop = r.exec(commands);Next time please paste your code between &#91;code&#93; tags with the help of the code button just above the edit message area.
    It makes the code MUCH more readable.
    Regards

  • I am not able to compile a program  on my mac...

    I am not able to compile a program  on my mac; i am getting the following message :"Class names, 'ClassName.Java', are only accepted if annotation processing is explicitly requested".  I am new to programming, and I am using a MAC. Any suggestions?  I am typing: "Javac ClassName.Java" at the command prompt.

    You might want to be posting to the developer forum here:
    https://discussions.apple.com/community/developer_forums

  • Could not able to RUN Java Programs in JRE 1.5.08

    hi
    I am using Jdk 1.5.8.
    I don�t have any problem in compiling the files.
    but i could not able to run the program through windows cmd prompt.
    Say name of the java file is newFile (no packages).
    When i try to run the program by using java newFile it raises a ClassNotFoundException.
    it s the same case when try to set any JDBC drivers ..
    is there any problem in my class path settings? Please help me out to fix this problem

    if your current directory is not in the classpath,you should include it in the classpath.
    To do that you can include .(dot) to your classpath variable.
    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html

  • OCI demos-not able to compile on red hat Linux

    Can anyone narrate how can I get the OCI routines (demo) working.
    I feel that they are failing to run. what are the check points needed
    that I should verify that an OCI program executes.
    Does this needs any special settings or running any script files
    before hand?.
    I am running on Red hat 6.1 and Oracle 8.1.6 based on Linux.
    when I detected the installations, following program folders are
    missing
    1. plsql/public
    2. lib/libextp.a
    I used one of the porgrams in the sample oci13.c and changed the user
    account and password. I then compiled as follows
    gcc -I(include files) -c oci13new.c
    But after this it gave me successfully the object file. But I could not
    able to link this to produce any a.out file!.
    Can anyone suggest how can I do this?
    Nat

    Step 1) is needed, you cannot got directly from 8.1.5 to 10g.
    When you are on level 8.1.7.4 (Step 2)) there are alternatives to export/import, for example DBUA. But first, you are right, you have to build up a 8.1.7.4 database on Linux, because this release does not allow other methods of transportation across different platforms. Or you import directly into a new built database on Linux.
    For database upgrade see
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14238/preup.htm#sthref52
    Step 3) is described step-by-step here:
    http://www.oracle.com/technology/pub/articles/chan_sing2rac_install.html

  • Not Able  to Compile Java code

    Hi Java Gurus
    I am not able to compile this code Pl help
    class For {
    public static void main (String [] args) {
    int I = 0;
    show:
         if (I < 2) {
    System.out.print("I is " + I);
    I++;
    continue show;
    }

    class For {
    public static void main (String [] args) {
          for(int i = 0; i < 2; i++){
                  System.out.print("I is " + i);
    }this does the same as your program: the for loop is the best for this, but i agree with the others read some tutorials on loops in java. As posted before java has no concept of the GoTo syntax, loops or recursion are your only options

  • Not able to compile servlet

    Hello
    I would like some one to help me.
    I have WindowsXp professional on my Laptop. I downloaded jdk and I am able to compile and run the core java files.
    I downloaded j2sdk1.4.2_10 from the website www.java.sun.com. and then set the path in the environment variables. But in the command promt I was not able to compile the servlet.
    Could you please guide me about what more has to be done so that The servlet can compile.
    Thanking you

    **MAJOR SPAMMING SCUM BAG ALERT**
    I was puzzled in that you asked a SQL Server question in one post and then in another thread asked a Oracle related question... and then I noticed you had cross posted one of your questions at JavaRanch and I was more annoyed....
    and then I found this....
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=10&t=002447
    You sir -> Michael Byrd -> are a scum sucking dirtbag.
    To quickly explain. Mr. Byrd posts his messages (which he copies wholesale from other posters) so that he can get better google caching for the website listed in his profile.
    This is such scummy behaviour I don't even know what to say. Other than basically everyone that has ever helped you had totally wasted their time.
    You are scum. Your company is scum. I hope you rot in hell.

  • Not able to compile wrapped package bodies.

    Hi All
    Can anybody pls help me finding me the reason why I m not able to compile .plb (wrapped package body). There are no compilation errors. But when I run the .plb file (as @xyz.plb), sqlplus window hangs. No error shown. Everytime I had to close the window after waiting for 8-10 minutes.
    This is happening only with 11 files out of 200.Rest were compiled.
    Any ideas? Do we have any other way to wrap than using pl/sql wrap utility or pl/sql plug-in for wrapping(which is actually the same as former)??
    ThanksInAdvance!!
    Keep striking the iron until it's hot!

    yes, I did check for locks from pl/sql developer only. No Locks.
    I waited for 10 minutes for a 6 kb .plb file to get compiled. But had to close the session after that.
    I am using oracle 10g, pl/sql developer 7.1.0.1337
    sql*plus Release 10.2.0.2.0

  • Not Able to compile Servlet from ?

    Hi All,
    I am not able to compile Servlet from my package:
    1) I Have set the CLASSPATH Variable using below line in System Variables:
    C:\CC4\prog\jakarta-tomcat-4.1.30\common\lib\servlet.jar
    2) Also Set the CATALINA_HOME with value
    C:\CC4\prog\jakarta-tomcat-4.1.30
    as per above setting servlet should be compiled but still i m getting error message:
    1) C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac ListenerTest
    er.java
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    ListenerTester.java:17: cannot resolve symbol
    symbol : class Dog
    location: class com.example.ListenerTester
    Dog dog = (Dog) getServletContext().getAttribute("dog");
    ^
    2 errors
    2) Error while compiling other file:
    C:\CC4\prog\jakarta-tomcat-4.1.30\project\classes\com\example>javac MyServletCon
    textListener.java
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    MyServletContextListener.java:12: cannot resolve symbol
    symbol : class Dog
    location: class com.example.MyServletContextListener
    Dog d = new Dog(dogBreed);
    ^
    2 errors
    So what could be the posible solution here :
    do reply !!!
    please
    Thanks
    prabhat

    I have added servlet.jar in the classpath. But the program is not compiling.The error message says that it can not find classes like ServletConfig, ServletException, Cookie etc. Please help.

  • NOT able to compile servlet and EE java files

    hi
    i am not able to compile java files of servlet
    it is showing cannot resolve symbol for servlet classes
    since i have installed tomcat j2sdk1.4.2_06 and also facing problem with the classpath since i have to set the classpath everytime as i have already created it in environment variables
    show me the way out

    **MAJOR SPAMMING SCUM BAG ALERT**
    I was puzzled in that you asked a SQL Server question in one post and then in another thread asked a Oracle related question... and then I noticed you had cross posted one of your questions at JavaRanch and I was more annoyed....
    and then I found this....
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=10&t=002447
    You sir -> Michael Byrd -> are a scum sucking dirtbag.
    To quickly explain. Mr. Byrd posts his messages (which he copies wholesale from other posters) so that he can get better google caching for the website listed in his profile.
    This is such scummy behaviour I don't even know what to say. Other than basically everyone that has ever helped you had totally wasted their time.
    You are scum. Your company is scum. I hope you rot in hell.

  • Could not save changes to this script because of a program error. -2706

    OK, this is very odd! Please try the following and let me know your results:
    1) Create a new script with the following example code:
    set testList to {}
    repeat with i from 1 to 8145
    copy i to end of testList
    end repeat
    2) Save the script as an Application (name it whatever you like).
    3) Launch the newly created Application and see if you get the same error message I am getting...
        *Could not save changes to this script because of a program error.*
        -2706
    If you replace the number 8145 with 8144 (or any number less than 8145) the script runs without error. Any number greater than 8144 returns the error message shown above. Maybe there's a reason for this that I'm overlooking or is this another bug?
    I looked up error code -2706 ([HERE|http://developer.apple.com/Mac/library/documentation/AppleScript/Concept ual/AppleScriptLangGuide/reference/ASLRerrorcodes.html]) which says it is a "*Stack overflow.*"
    Thanx in advance for any insight on this!!
    NOTE:
    The only workaround I've found for this is to make sure the script resets the variable before it quits. Like this:
    set testList to {}
    repeat with i from 1 to 8145
    copy i to end of testList
    end repeat
    set testList to ""

    Hey Pierre, thanx for taking the time to scratch your head with me!
    Very odd indeed.
    Glad it's not just me that thinks this!
    I've also noticed that the problem occurs even when you try to save the script as a compiled script. That's possible as long as you haven't run the script. Once you have run it, trying to save it seems impossible. You get the message: *“The document “Document title” could not be saved.”*
    I've noticed the same thing as you and have experienced this extra error several times while trouble shooting this problem!
    On the other hand, is there any good reason for which you would want to save such a big list? Are there any drawbacks to the workaround you've found?
    I don't want to save ANY variable EVER unless I explicitly tell my script to do so! This variable is not a property, so why would my script want to save it? I haven't noticed any drawbacks to the workaround. Setting the list variable to "" or {} (or ANYthing with under 8145 items) seems to work fine. I just find it weird that my script can't "*save changes to itself*"?! What is there to save? It's just a variable that should release after my script has run ...unless I'm completely misunderstanding how variables work after ALL these years of scripting.
    Btw, the following version of the script (as you probably already know) is much faster, although it doesn't change anything to the result:
    *set testList to {}*
    *set testListRef to a reference to testList*
    *repeat with i from 1 to 8144*
    *copy i to end of testListRef*
    *end repeat*
    Yeah, it definitely runs much faster this way! I just posted a quick example that would illustrate the 8144 list count limit. My script sets a variable to a list of numbers contained in a text file. This list is almost always rather large! Right now there are over 20,000 items in this list of numbers.
    Again, thanx for your time my friend!!

  • Hi. Good morning, I intend to purchase the Photography Photoshop program. The Rs 499/month one. I currently use an Mac Air. But intend to buy a iMac in about 2 months time. Will I be able to transfer this program or continue using this on my new machine?

    Hi. Good morning, I intend to purchase the Photography Photoshop program. The Rs 499/month one. I currently use an Mac Air. But intend to buy a iMac in about 2 months time. Will I be able to transfer this program or continue using this on my new machine?

    My eyes just glazed over...Please in the future break down each of your issues with paragraphs separated by two carriage returns. It would be much easier when trying to address your issues.
    Go to Apple menu -> System Preferences -> Keyboard and Mouse -> Mouse
    And edit your mouse settings to do what you want it to do.
    Secondly, this is not the place to vent. If you have a complaint, there is:
    http://www.apple.com/feedback/
    or http://www.apple.com/contact/
    We are just end users here helping other end users.
    Third, from my understanding, it would appear you are concerned about the noise the hard drive makes when it falls asleep? Why not put your machine in screen saver mode instead? Apple menu -> System Preferences -> Energy Saver turn off all Energy Saver settings, or set them to run Never.
    Fourth, if your machine was purchased just a few days ago, you may still be able to get an exchange from the store, quicker than you can get a repair done. You may want to look into that possibility.
    Fifth, it does appear you found the Logic forum. I would persist in asking there how to solve your technical issue with Logic regarding the audio. It may be you don't have to do anything special to the hard drive. Remember audio can be transmitted by wire, avoiding ambient sounds.
    Good luck!

  • I was subscribed to Adobe CC, it ended, i subscribed again and now im not able to open any program, but adobe already charged my credit card

    I was subscribed to Adobe CC, it ended, i subscribed again and now im not able to open any program, but adobe already charged my credit card

    Since this is an open forum, not Adobe support... you need to contact Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

Maybe you are looking for