windows - Java, Import Class From File -


i'm writing java program , wanted make class can called on make quick log cmd (i'm still in testing phase, figuring stuff out). have file , folder file in it.

  • launchprogram.java
  • helping
    • dbg.class
    • dbg.java

the summarized contents of launchprogram.class (the stuff relevant):

import helping.dbg;  public class launchprogram{     public static void main(string[] args){         dbg("testing");     } } 

the contents of dbg.class:

package helping;  public class dbg{     public static void main(string message){         system.out.println(message);     } } 

when javac dbg.java in cmd, runs without error, producing dbg.class.

when javac launchprogram.java in cmd, following error:

launchprogram.java:5: error: cannot find symbol                 dbg("testing");                 ^ symbol:   method dbg(string) location: class launchprogram 

i'm not sure what's happened cause this, , i've looked everywhere can't find solution. know causing issue , how fix it?

here corrected code trying do:

public class launchprogram {     public static void main(string[] args){         dbg.log("testing");     } }  public class dbg {     public static void log(string message){         system.out.println(message);     } } 

but apache log4j better way logging in application. here skeleton code launchprogram class uses log4j log message:

import org.apache.logging.log4j.logmanager; import org.apache.logging.log4j.logger;  public class launchprogram {     static final logger logger = logmanager.getlogger(launchprogram.class.getname());      public static void main(string[] args){         logger.info("testing");     } } 

note don't need separate class log, rather can log directly class need record message.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -