Re: Newbie question - on syntax error
On Jul 15, 9:46 am, "StephenM" <sawdustnos...@primelink1.net> wrote:
I am completely new to java [sic] so bear with me.
...
I am getting a syntax error: "cannot find symbol: variable LibClass". The
code is pasted directly from the tutorial so it should be accurate.
Accurate, but incomplete.
You used an unqualified class name 'LibClass' (terrible name for a
class in real life, BTW) within Main, that is, you did not include the
package name in the class reference:
String result = org.me.mylib.LibClass.acrostic(args);
The class needs to be referred to by its fully-qualified name (FQN)
for the compiler and runtime to find it. You get the FQN either by
spelling it out, as I just showed, or by importing the FQN so the rest
of the compilation unit can alias the simple name to the FQN.
After the 'package' declaration of the client module (Main):
import org.me.mylib.LibClass;
package acrostic;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String result = LibClass.acrostic(args);
System.out.println("Result = " + result);}}
package org.me.mylib;
public class LibClass {
...
--
Lew