0

I have this Java code:

import acm.program.*;
public class test extends Program 
{
    public void run () { println ("Hello World!!!");}
}

When I try to compile it I get this:

izzy@izzy-VPCEB1S1E:~/Java$ javac -cp acm.jar test.java test.java:1: error: package acm.jar does not exist

import acm.jar.*;

^ test.java:3: error: cannot find symbol

public class test extends Program {
                      ^   symbol: class Program test.java:4: error: cannot find symbol


public void run () { println ("Hello World!!!");}
                   ^   symbol:   method println(String)   location: class test 3 errors
Zombo
  • 1
  • 62
  • 391
  • 407
  • Is the file `acm.jar` in the current directory? – yiding Aug 21 '15 at 21:08
  • question is not clear can u please elaborate ... – NIKET BHANDARY Aug 21 '15 at 21:13
  • If you are useing eclipse, see this how-to-import-a-jar-in-eclipse http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse – luoluo Aug 21 '15 at 23:08
  • First of all, thank you guys for trying to help me @yiding Yes, the acm.jar is in the same directory as the source code. – Fajkor Kastrioti Aug 23 '15 at 07:36
  • NIKET BHANDARY Could you please be more specific? What is that is not clear? This piece of code is from a tutorial from a Greek university. It told us to write this code in a text file, with the extension .java. The source file in in the same same directory as the acm.jar archive. – Fajkor Kastrioti Aug 23 '15 at 07:46
  • luoluo Im not using eclipse. Im using Geany. The source file that i create has the extension .java. And then, i try to compile it writing in the terminal javac -cp acm.jar test.java – Fajkor Kastrioti Aug 23 '15 at 07:46
  • The code snippet in your comment does not contain the line that `javac` is complaining about. Please post the output of `cat test.java`. – Matt McHenry Aug 24 '15 at 01:10
  • @Matt McHenry I'm sorry, but because I am very very beginer, how can I get the output of cat test.java? Can you tell me what exactly to type in the terminal. – Fajkor Kastrioti Aug 24 '15 at 13:37
  • @FajkorKastrioti that's exactly what you should type: `cat test.java`. It will simply print the entire contents of the test.java file to the terminal. – Matt McHenry Aug 24 '15 at 16:44
  • @Matt McHenry I typed cat test.java in the terminal. Here's the output: izzy@izzy-VPCEB1S1E:~/Java$ cat test.java import acm.program.*; public class test extends Program { public void run() { println("Hello world!!!"); } } izzy@izzy-VPCEB1S1E:~/Java$ – Fajkor Kastrioti Aug 26 '15 at 18:27
  • @MattMcHenry By the way, this piece of code is being compiled now and running. I dont know what went wrong the first time. Anyway, thanx again for your help. – Fajkor Kastrioti Aug 26 '15 at 18:30

0 Answers0