Note that there are some explanatory texts on larger screens.

plurals
  1. POjar and cannot find symbol for method (but other class methods are found)?
    primarykey
    data
    text
    <p>I really have problem with this one. </p> <p>So I have a jar with a class for handling a database connection. In that class I have put several methods. Out of this class I have created a jar using Ant. </p> <p>Sometime yesterday I suddenly could not access the latest method in that db class anymore. I get:</p> <pre><code>compile: [javac] C:\cygwin\home\user\Dev\Java\avc_alarm\build.xml:22: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to C:\cygwin\home\user\Dev\Java\avc_alarm\build [javac] C:\cygwin\home\user\Dev\Java\avc_alarm\src\se\gefa\avc_alarm\Main.java:9: error: cannot find symbol [javac] symbolAliases = db.getAlarmSymbolAlias(); [javac] ^ [javac] symbol: method getAlarmSymbolAlias() [javac] location: variable db of type AvcDb [javac] 1 error </code></pre> <p>Code that tries to use this class method:</p> <pre><code>package se.gefa.avc_alarm; import se.gefa.avc_db.AvcDb; import java.util.ArrayList; public class Main { static AvcDb db = new AvcDb(); static ArrayList&lt;String&gt; symbolAliases; public static void main(String args[]) throws Exception { db.setupConnection("jdbc:h2:tcp://localhost/C:/XXXX/xyz", "sa", ""); symbolAliases = db.getAlarmSymbolAlias(); } } </code></pre> <p>And the db class (which goes into a jar):</p> <pre><code>package se.gefa.avc_db; import java.sql.*; import java.util.ArrayList; public class AvcDb { // --- // Other methods that DO work // --- // The one that DO NOT work public ArrayList&lt;String&gt; getAlarmSymbolAlias() throws Exception { String query = "SELECT * FROM Alarm"; Statement statement = conn.createStatement(); ResultSet resultSet = statement.executeQuery(query); ArrayList&lt;String&gt; symbols = new ArrayList&lt;String&gt;(); while (resultSet.next()) symbols.add(resultSet.getString("symbol_alias")); return symbols; } } </code></pre> <p>I'm using java 7, Ant 1.8.3 and Vim. When opening the db jar in IntelliJ I can see that the getAlarmSymbolAlias method exists. And as I said, I could call any other of the methods for the db class except any method added yesterday. A simple test in IntelliJ and it seems to work (but I don't want to learn a new Editor when I got all other set up in Vim, CL and Ant.</p> <p><strong>Edit</strong> Ant script:</p> <pre><code>&lt;project name="AvcAlarm" default="dist" basedir="."&gt; &lt;description&gt; Alarm program. &lt;/description&gt; &lt;property name="src" location="src"/&gt; &lt;property name="build" location="build"/&gt; &lt;property name="dist" location="dist"/&gt; &lt;property name="lib" location="lib"/&gt; &lt;path id="classpath"&gt; &lt;fileset dir="${lib}" includes="**/*.jar"/&gt; &lt;/path&gt; &lt;target name="init"&gt; &lt;tstamp/&gt; &lt;mkdir dir="${build}"/&gt; &lt;mkdir dir="${dist}"/&gt; &lt;/target&gt; &lt;target name="compile" depends="init" description="compile the source " &gt; &lt;javac srcdir="${src}" destdir="${build}" classpathref="classpath"/&gt; &lt;/target&gt; &lt;target name="dist" depends="compile" description="generate the distribution" &gt; &lt;jar destfile="${dist}/gefa_alarm.jar" basedir="${build}"&gt; &lt;zipgroupfileset dir="lib" includes="*.jar" /&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="se/gefa/avc_alarm/Main"/&gt; &lt;/manifest&gt; &lt;/jar&gt; &lt;/target&gt; &lt;target name="clean" description="clean up" &gt; &lt;delete dir="${build}"/&gt; &lt;delete dir="${dist}"/&gt; &lt;/target&gt; &lt;/project&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload