Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Error explanation please

 
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am getting the following error message:-

java.lang.StackOverflowError @ us_copiosus_EURNZD_TSFDC_Live$WekaApp.<init>(us_copiosus_EURNZD_TSFDC_Live.java:693)

Within my main program I have the following code:-



and the WekaApp Class is as follows:-



Can somebody please help me understand the error message

Bob M
 
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This is infinite recursion which eats away at the stack memory till it's gone - hence, exception.

WekaApp() is the constructor
new WekaApp() calls the constructor

Not sure what you are trying to do but this might be what your after.
Nope. Sorry. Still don't know what you're trying to do.
 
Carey Brown
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the rest of your code it seems like you need an instance of WekaApp but you're not using the wekaApp variable anywhere so you don't need it. In that case get rid of your constructor and use a default no argument constructor which will be implicitly provided for you.
 
Rancher
Posts: 990
23
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getting out my crystal ball and trying to expand on what Carey said:



and change this:


to this


and if i am correct, you'll have an instance variable, which is what i think you want.
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys............

The code I have now in my main program......................



and the top of the class wekaApp is............



Compilation error: syntax error, insert "}"to complete MethodBody on wekaAPP.init(); line
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the package that I am trying to adapt to my environment..........
 
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This is the package that I am trying to adapt to my environment..........


What happens when you compile and execute that code?
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Norm.............

I have tried to setup weka projects in Netbeans but never succeeded..........

All the google references I can find are well out of date and do not represent NetBeans 12.5 version

And so, I don't know how to compile the adams package as a stand alone

The package came from Peter Reutemann ( one of weka's creators)

Bob M
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have the jarfile containing the packages listed at the head of the program?
Given that, try compiling the program in a command prompt with that jarfile given with the -cp option:
javac -cp TheWekaPackages.jar;.   WekaApp.java
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I received the following messages...............

At line:22 char:20
+   public void init() throws Exception {
+                    ~
An expression was expected after '('.
At line:38 char:23
+     if (header == null)
+                       ~
Missing statement block after if ( condition ).
At line:40 char:34
+     return header.classAttribute().value(index);
+                                  ~
An expression was expected after '('.
At line:40 char:42
+     return header.classAttribute().value(index);
+                                          ~
Missing ')' in method call.
At line:37 char:66
+   public String getLabel(int index) throws IllegalStateException {
+                                                                  ~
Missing closing '}' in statement block or type definition.
At line:9 char:22
+ public class WekaApp {
+                      ~
Missing closing '}' in statement block or type definition.
At line:40 char:47
+     return header.classAttribute().value(index);
+                                               ~
Unexpected token ')' in expression or statement.
At line:41 char:3
+   }
+   ~
Unexpected token '}' in expression or statement.
At line:54 char:57
+       double[] values = new double[header.numAttributes()];
+                                                         ~
An expression was expected after '('.
At line:55 char:25
+       for (int i = 0; i < values.length; i++)
+                         ~
The '<' operator is reserved for future use.
Not all parse errors were reported.  Correct the reported errors and try again.
   + CategoryInfo          : ParserError: ( [], ParentContainsErrorRecordException
   + FullyQualifiedErrorId : ExpectedExpression

Bob M
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is really strange.  I found and downloaded a jar file for weka packages, created a batch file to call the javac program and executed it without any compiler errors.  My batch file's contents:

javac.exe -cp .;weka-dev-3.7.6.jar  WekaApp.java
MORE


I am on a Win10 system.
javac.exe version is:

Microsoft Windows [Version 10.0.19044.1348]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Norm>javac -version
javac 1.8.0_60

C:\Users\Norm>



what version of the javac program did you use?
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac 16.0.1

windows 10 system
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you run the javac program in a command prompt again and copy the full contents of the window and paste it here so we can see the command line and the full output of the compiler?

Here is the contents of the command prompt window when I use javac from jdk17


D:\JavaDevelopment\Testing\ForumQuestions13>D:\Java\jdk-17\bin\javac.exe -cp .;weka-dev-3.7.6.jar  WekaApp.java

D:\JavaDevelopment\Testing\ForumQuestions13>MORE


If there were any errors they should show where the blank line is.
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
struggling here ................

PS C:\Windows\system32> C:\Program Files\Java\jdk-16.0.1\bin\javac.exe -cp .:weka-3.8.5.jar WekaApp
C:\Program : The term 'C:\Program' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\Program Files\Java\jdk-16.0.1\bin\javac.exe -cp .:weka-3.8.5.jar W ...
+ ~~~~~~~~~~
   + CategoryInfo          : ObjectNotFound: (C:\Program:String) [], CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32>
 
Marshal
Posts: 74393
335
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you working in the System32 folder? Why don't you update your PATH environment variable to include the path to the Java® installation folder?
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry...........

C:\Program Files\Java\jdk-16.0.1\bin>javac.exe -cp .;weka.jar  WekaApp.java
error: file not found: WekaApp.java
Usage: javac <options> <source files>
use --help for a list of possible options

C:\Program Files\Java\jdk-16.0.1\bin>

now, I need to be specific as to where the WekaApp.java file is located
 
Carey Brown
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My head is exploding here.
NEVER go into C:\windows\ANYTHING
NEVER go into C:\Program Files\ANYTHING

Stay out of those places! If you think you need to be there then STOP because you're doing something wrong. Not using your PATH environment variable is a likely suspect.
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Program Files\Java\jdk-16.0.1\bin>javac.exe -cp .;weka-3.8.5.jar C:\users\rgmat\Desktop\WekaApp.java
C:\users\rgmat\Desktop\WekaApp.java:3: error: package weka.classifiers does not exist
import weka.classifiers.Classifier;
                      ^
C:\users\rgmat\Desktop\WekaApp.java:4: error: package weka.core does not exist
import weka.core.DenseInstance;
               ^
C:\users\rgmat\Desktop\WekaApp.java:5: error: package weka.core does not exist
import weka.core.Instances;
               ^
C:\users\rgmat\Desktop\WekaApp.java:6: error: package weka.core does not exist
import weka.core.SerializationHelper;
               ^
C:\users\rgmat\Desktop\WekaApp.java:7: error: package weka.core does not exist
import weka.core.Utils;
               ^
C:\users\rgmat\Desktop\WekaApp.java:12: error: cannot find symbol
 protected Classifier cls;
           ^
 symbol:   class Classifier
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:15: error: cannot find symbol
 protected Instances header;
           ^
 symbol:   class Instances
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:25: error: cannot find symbol
   Object[] objs = SerializationHelper.readAll("/home/fracpete/temp/j48.model");
                   ^
 symbol:   variable SerializationHelper
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:26: error: cannot find symbol
   cls = (Classifier) objs[0];
          ^
 symbol:   class Classifier
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:27: error: cannot find symbol
   header = (Instances) objs[1];
             ^
 symbol:   class Instances
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:56: error: cannot find symbol
       values[i] = Utils.missingValue();
                   ^
 symbol:   variable Utils
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:59: error: cannot find symbol
     DenseInstance currentInstance = new DenseInstance(1.0, values);
     ^
 symbol:   class DenseInstance
 location: class WekaApp
C:\users\rgmat\Desktop\WekaApp.java:59: error: cannot find symbol
     DenseInstance currentInstance = new DenseInstance(1.0, values);
                                         ^
 symbol:   class DenseInstance
 location: class WekaApp
13 errors

C:\Program Files\Java\jdk-16.0.1\bin>
 
Campbell Ritchie
Marshal
Posts: 74393
335
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where exactly did you put your Weka .jar file?
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

C:\Program Files\Java\jdk-16.0.1\bin>



Following Campbell's warnings, don't do anything inside of the JDK's folders.

Look at the contents of the batch file I posted.  That batch file was in the same folder as the .java and .jar files.  All three files were in the same folder.
The batch file referred to the javac.exe file by using the full path to the javac.exe file's location.
If the path contains spaces, enclose it in "s


" C:\Program Files\Java\jdk-16.0.1\bin\javac.exe" -cp .:weka-3.8.5.jar WekaApp.java

 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\weka_3.8.5\weka_3.8.5
 
Campbell Ritchie
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that the same location as you are adding to your CLASSPATH? What happens if you use -cp C:\weka_3.8.5\weka_3.8.5 etc?
Don't copy'n'paste this post because it contains hard spaces.
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For simplicity and testing I recommend that you put all three files in the same folder.  When that works, move the files to their locations and change the batch file to map to their new locations.  
The idea is to remove  many potential problems to start with and then add them back one at a time, making changes as needed to keep it working.
 
Campbell Ritchie
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It also shows that we need the full details for any question.
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c:\Data Analysis>javac.exe -cp .;weka.jar  WekaApp.java

Error: jli.dll not found

All 3 programs are in Data Analysis folder
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c:\Data Analysis>>"C:\Program Files\Java\jdk-16.0.1\bin\javac.exe" -cp .;weka.jar  WekaApp.java

Error: Access denied
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c:\Data Analysis>"C:\Program Files\Java\jdk-16.0.1\bin\javac.exe" -cp .;weka.jar  WekaApp.java

no errors ???
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now have WekaApp.class class file in the Data Analysis folder
 
Carey Brown
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Matthews wrote:c:\Data Analysis>"C:\Program Files\Java\jdk-16.0.1\bin\javac.exe" -cp .;weka.jar  WekaApp.java


Fix. Your. PATH.
You don't need the long path name if you'd only fix your PATH. Helps eliminate typos.
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

no errors ???


Ok, now the compile step has worked.

What happens when you execute the class file using the java.exe command?


Error: jli.dll not found


Is there another javac.exe file that is located via the PATH environment variable?
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
path for JAVA_HOME

C:\Program Files\Java\jdk-16.0.1\bin

do I need a "\" on the end?
 
Carey Brown
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Matthews wrote:path for JAVA_HOME

C:\Program Files\Java\jdk-16.0.1\bin

do I need a "\" on the end?


Actually, JAVA_HOME doesn't end with a backslash OR the "bin".

For PATH, put this in the very front
%JAVA_HOME%\bin;
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to run WekaApp class I get the following error message:-

C:\Data Analysis>java WekaApp
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: WekaApp has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(Unknown Source)
       at java.security.SecureClassLoader.defineClass(Unknown Source)
       at java.net.URLClassLoader.defineClass(Unknown Source)
       at java.net.URLClassLoader.access$100(Unknown Source)
       at java.net.URLClassLoader$1.run(Unknown Source)
       at java.net.URLClassLoader$1.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

C:\Data Analysis>
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
updated to jdk-16.0.1

now error message:

C:\Data Analysis>java WekaApp
Error: Could not find or load main class WekaApp
Caused by: java.lang.NoClassDefFoundError: adams/WekaApp (wrong name: WekaApp)

C:\Data Analysis>
 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
commented out package name

now we have the following error:-

c:\Data Analysis>java WekaApp
Error: Unable to initialize main class WekaApp
Caused by: java.lang.NoClassDefFoundError: weka/core/Instance

c:\Data Analysis>
 
Campbell Ritchie
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stop guessing.
Correct your system PATH.
Give us the full details of where you are working and where those dependencies are.
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jar file needs to be passed to the java command using the -cp option the same way it was passed to the javac command.

"C:\Program Files\Java\jdk-16.0.1\bin\java.exe" -cp .;weka.jar  WekaApp

 
Bob Matthews
Rancher
Posts: 623
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Norm

Many thanks for your assistance to date..........

I am progressing, slowly............

Where I am at the moment:-

C:\Data Analysis>"C:\Program Files\Java\jdk-16.0.1\bin\java.exe" -cp .;weka.jar WekaApp
ERROR init: java.lang.ClassNotFoundException: Unable to find class weka.classifiers.meta.AutoWEKAClassifier
java.lang.ClassNotFoundException: Unable to find class weka.classifiers.meta.AutoWEKAClassifier
       at weka.core.SerializationHelper$1.resolveClass(SerializationHelper.java:363)
       at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2005)
       at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1872)
       at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2179)
       at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1689)
       at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:495)
       at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:453)
       at weka.core.SerializationHelper.readAll(SerializationHelper.java:399)
       at weka.core.SerializationHelper.readAll(SerializationHelper.java:380)
       at WekaApp.init(WekaApp.java:23)
       at WekaApp.main(WekaApp.java:83)
Weka exception occurred: java.lang.NullPointerException: Cannot invoke "weka.core.Instances.numAttributes()" because "this.header" is null
java.lang.NullPointerException: Cannot invoke "weka.core.Instances.numAttributes()" because "this.header" is null
       at WekaApp.currentInstance(WekaApp.java:52)
       at WekaApp.main(WekaApp.java:91)
Failed to make prediction!

C:\Data Analysis>
********************************************************
AutoWEKA classifier is a meta classifier - a special classifier
I may need a further java file ?

I will take a break here while I investigate this special classifier

Bob M
 
Carey Brown
Saloon Keeper
Posts: 8779
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't need the path in front of "java" or the ".exe" after it.
I thought you fixed that?
You can always run: java -version
to check.
 
Norm Radder
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

AutoWEKA classifier is a meta classifier - a special classifier
I may need a further java file ?


It looks like that is true.  I assume that you have the j48.model file at the path specified in the program at line 23.
It looks like the SerializationHelper.readAll method is reading the j48.model file and needs the class mentioned in the error message to do its processing.


Worry about the optimizations later.
 
reply
    Bookmark Topic Watch Topic
  • New Topic