Not able to compile java program

Hi
   I a using Netweaver to deelope the java code.I have written a javaprogram .But when choose the option Run as
a javaApplication it giving the following error
Source locator  doesnot Exist:org.eclipse.jdt.debug.ui.javaSourceLocator

Hi,
I am able to compile and run perfectly Java programs. The steps goes as:
1. File --> New --> Project --> Java --> Java Project --> give a <project name> --> Finish
2. File --> New --> Class --> give a classname, and package name.
3. Put main method and give a System.out.println("Hello");
Source code:
package com.i3l.trg;
public class HelloWorld {
     public static void main(String[] args)      {
          System.out.println("Hello");          
4.Goto Run --> Run As --> 2 Java Application.
5. You will get a output as "Hello" in java console.
Cheers!!!
Sukanta Rudra
PS: Liberally donate points.
The full source code is

Similar Messages

  • 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

  • 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 my program

    Sorry to post a very basic question in this forum, but I am very new to java, and I have just installed J2SDK in my system, which is having Windows 2000 Professional (OS). My question is in which directory (path).... we need to save our (.java) programs... if we have to compile it at C prompt ?, as it is not compiling my program with javac command. I included the bin path in control panel > environments tab, but it didn't help me.
    Many thanks in advance
    Manish

    ahhh simple... windows processes pick up the PATH (et al) a process creation time... close cmd and try again.
    ... and you DO NOT put .java programs in the java system bin directory. That's just sooooo silly it's not funny!
    append :. (colon dot) to the CLASSPATH... classes with no package will compile and run in the present working directory.
    When you get into packages see: The K-Zone: Mastering the Java CLASSPATH

  • I'm not able to compile my programs

    From the beginning i write the program and then i save it in C:\jdk1.3.1_02\bin\ as FirstApplet.java. I then go to dos and type: javac FirstApplet.java I get the above error. I dont know what to change.

    is it FirstApplet.java or My Applet.java? What exactly are you typing in? You can't have a class name with a space in it and a public class must be save in a file with the same name.
    If you are using Notepad to create the source code, Notepad might be saving your file as FirstApplet.java.txt instead of FirstApplet.java. You might not be able to see this if you look in a Windows folder if the folder is configured to not display file extensions. Go to a DOS window and use the dir command to see if your .java file exists where you think it is. (You need to CD to the directory where the .java file is before using javac, or you need to give javac the path to the file.)

  • Not able to run java programs

    Exception in thread "main" java.lang.NoClassDefFoundError. I have set the path and classpath but in user variables. And defined main in my programs. But programs are only compiling not running.
    Please suggest me.
    What do I do?
    Edited by: Ram-Murthy on Apr 10, 2008 2:23 AM

    Make sure your main is static.
    public static void main(String [] args) {}

  • Java Mapping - Not able to compile .Java file

    Hi Experts,
    I am working with a sample scenario which involves Java Mapping. For this I created MappingClass.java file, After compiling the .Java file .Jar file would be used for Java Mapping by using Imported Archives.
    After compiling the MappingClass.java file, I am getting the errors as below.
    --> Java errors after compilation
    C:\j2sdk1.4.2_13\bin>javac MappingClass.java
    MappingClass.java:4: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.AbstractTrace;
                                   ^
    MappingClass.java:5: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    --> End of java errors
    In the MappingClass.java file, I had given followed imports.
    import java.util.*;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    Could some one please guide me to resolve this issue.
    Thanks in advance.
    ..Sree

    Hi
    I had copied " aii_map_api.jar " file in my Java Class path folder.. i.e " C:\j2sdk1.4.2_08\bin "     AND    " C:\j2sdk1.4.2_08\lib " folders too.. and even in C:\ i.e Root Drive also.
    After trying to Compile my java file (ex : MappingClass.java), still I am getting the errors.
    Errors shown as below.
    --> Errors
    C:\mytest>javac MappingClass.java
    MappingClass.java:2: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.AbstractTrace;
                                   ^
    MappingClass.java:3: package com.sap.aii.mapping.api does not exist
    import com.sap.aii.mapping.api.StreamTransformationConstants;
                                   ^
    MappingClass.java:6: cannot resolve symbol
    symbol  : class AbstractTrace
    location: class MappingClass
        private static AbstractTrace trace = null;
                       ^
    MappingClass.java:12: cannot resolve symbol
    symbol  : class AbstractTrace
    location: class MappingClass
            trace = (AbstractTrace)inputparam.get(
                     ^
    MappingClass.java:13: cannot resolve symbol
    symbol  : variable StreamTransformationConstants
    location: class MappingClass
                       StreamTransformationConstants.MAPPING_TRACE );
                       ^
    5 errors
    --> End of Errors
    Could some one please guide me to resolve this issue.
    Thanks in advance.
    ..Sree

  • 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

  • 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.

  • 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.

  • How to compile java programs in j2EE 1.4 SDK

    hi,
    i HAVE JUST INSTALLED NEW J2EE 1.4 SDK , IT HAS BEED INSTALLED SUCCESFULLY BUT I AM UNABLE TO COMPILE JAVA PROGRAMS WHICH I USED TO RUN IN SDK 1.4 ,OR EVEN NEW WRITTEN EXAMPLES. CAN ANYONE PLZ HELP ME.

    J2EE by itself is not capable of compiling Java. It requires that a J2SDK be installed first - this is what compiles and runs Java programs. Did you install the combination J2SDK and J2EE, or just the J2EE?
    If both are installed, then you should be able to compile and run as you used to..

  • 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.

  • Compiling Java Program thro EXEC

    hi..
    I want to compile java programs programatically. I am using exec for that. The problem is there is a error in the i am no getting any message from that Process .will u help me how to solve this
    URGENT
    pyari
    Code Snippet
              try
                                  String command = "cmd /c javac -classpath c:\\j2ee\\home\\ejb.jar -d "+
                                  "c:\\javapr~1\\WeblogicEJBComplier\\tempBuild "+
                                  "C:\\j2ee\\home\\demo\\ejb\\cart\\CartClient.java";
         System.out.println(command);
         Runtime rnt = Runtime.getRuntime();
                                  Process prs = rnt.exec(command);
                                  BufferedReader bfr = new BufferedReader(new InputStreamReader(prs.getInputStream()));
                                  String str = bfr.readLine();
                                  System.out.println(str);
                                  while(str!=null)
                                       System.out.println(str) ;
                                       str = bfr.readLine();
              }catch(Exception eo)
                   System.err.println(eo);

    javac writes the errors in stderr, not in stdout.
    So replace getInputStream() with getErrorStream()...

  • HELP for Compile java programe !

    Hello All,
    i want to make java programe by which i can compile java programes
    and when i compile java programe from my programe then
    i shoul get compiled status means programe compile successfuly
    or not compile.
    if any example i m thanksfull.
    onlyforjava.

    how about if compile fail?
    the process obj seems return value 0 as it run successful.
    I haven't try this, but I have experienced the process obj returns 0 if the executed command has some routine to handle error cases, in which, error will not halt the system.
    So, I recommand the following scenario.
    1. let say, if your java is test.java. check the existence of file test.class.
    If, it exists, get its modified time.
    2. compile the java code with
    Procress p = Runtime.exec(new String[]{"javac", "test.java"});
    3. get the error string if any.
    InputStream in = new BufferedInputStream(p.getInputStream());int read;while ((read = in.read()) != -1){  System.out.println((char)read);}
    4. handle error with the exitValue
    if (p.exitValue() != 0){  System.out.println("warning.");}
    5. check again the file test.class if it is a newly created file.
    6. if it is newly created, compile success. Else, failed.

Maybe you are looking for