Java errors in simple SBC2 program

Supporting Java SE version 7 and up
CohesiveTechnology
Phidgetly
Posts: 15
Joined: Sat Jun 11, 2011 6:34 pm
Location: Keene, NH USA
Contact:

Java errors in simple SBC2 program

Postby CohesiveTechnology » Tue Jun 21, 2011 2:50 pm

I have a first-chance exception that I do not understand. This is a very simple class that needs to run on my SBC2.

Code is below; Message follows:

Code: Select all

Exception in thread "main" java.lang.NoClassDefFoundError: i4c/auxillary/Switches (wrong name: com/CohesiveTechnology/i4c/auxillary/Switches)
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
   at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: i4c.auxillary/Switches. Program will exit.


If this were an application on my desktop I would look at path and application variables. But this is on the SBC2 (seen in stderr, in my browser).

Does anyone have a clue as I do not. FYI: C++, C# developer here; I am Java challenged.

Any help would be appreciated.

Code: Select all

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.CohesiveTechnology.i4c.auxillary;
import com.phidgets.InterfaceKitPhidget;
import com.phidgets.PhidgetException;

public class Switches
{
    private static InterfaceKitPhidget ifk8;
    private static InterfaceKitPhidget ifk4;
   
    public static void main(String args[])
    {
        try
        {
            ifk8 = new InterfaceKitPhidget();
            ifk4 = new InterfaceKitPhidget();
           
            ifk8.open (48071,"i4csbc1");
            ifk4.open (108986,"i4csbc1");
           
            do
            {
                if (ifk8.getInputState(1)== true)
                {
                    ifk8.setOutputState(1, true);                   
                }
                else
                {
                    ifk8.setOutputState(1, false);                   
                }
               
                if (ifk8.getInputState(2)== true)
                {
                    ifk8.setOutputState(2, true);                   
                }
                else
                {
                    ifk8.setOutputState(2, false);                   
                }
               
                if (ifk8.getInputState(3)== true)
                {
                    ifk8.setOutputState(3, true);
                    ifk4.setOutputState(1, true);
                }
                else
                {
                    ifk8.setOutputState(3, false);
                    ifk4.setOutputState(1, false);
                }
               
                if (ifk8.getInputState(4)== true)
                {
                    ifk8.setOutputState(4, true);
                    ifk4.setOutputState(4, true);
                }
                else
                {
                    ifk8.setOutputState(4, false);
                    ifk4.setOutputState(4, false);
                }
               
                if (ifk8.getInputState(5)== true)
                {
                    ifk8.setOutputState(5, true);
                    ifk4.setOutputState(2, true);
                }                       
                else
                {
                    ifk8.setOutputState(5, false);
                    ifk4.setOutputState(2, false);
                }
               
                if (ifk8.getInputState(6)== true)
                {
                    ifk8.setOutputState(6, true);
                    ifk4.setOutputState(3, true);
                }
                else
                {
                    ifk8.setOutputState(6, false); 
                    ifk4.setOutputState(3, false);
                } 
               
                Thread.sleep(1000);
            }while (true);

        }
        catch (PhidgetException ex)
        {
           
        }
               
        catch (Exception ex)
        {
           
        }
       
        finally
        {
            ifk8 = null;
            ifk4 = null;
        }
               
    }
}
DJF

David Falkenstein
Cohesive Technology - seamless is everything

User avatar
Patrick
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Java errors in simple SBC2 program

Postby Patrick » Tue Jun 21, 2011 2:57 pm

get rid of the package statement up top.

-Patrick

RBBT
Phidgeteer!
Posts: 90
Joined: Sun Nov 15, 2009 2:16 pm
Location: Lower Bavaria (Germany)
Contact:

Re: Java errors in simple SBC2 program

Postby RBBT » Tue Jun 21, 2011 3:00 pm

Hello,
would you please post the content of your manifest file?
Best Regards from Lower Bavaria
RBBT
http://www.robobuam.de/

CohesiveTechnology
Phidgetly
Posts: 15
Joined: Sat Jun 11, 2011 6:34 pm
Location: Keene, NH USA
Contact:

Re: Java errors in simple SBC2 program

Postby CohesiveTechnology » Tue Jun 21, 2011 4:42 pm

I commented out the package statement. No joy.

Manifest.mf follows:

Code: Select all

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build


I know this works because I can access it from my core using C#. In this case I am testing the SBC as a stand-alone fail-safe operation.
DJF

David Falkenstein
Cohesive Technology - seamless is everything

RBBT
Phidgeteer!
Posts: 90
Joined: Sun Nov 15, 2009 2:16 pm
Location: Lower Bavaria (Germany)
Contact:

Re: Java errors in simple SBC2 program

Postby RBBT » Tue Jun 21, 2011 11:13 pm

Hello,

the Main-Class attribute must be:

com.CohesiveTechnology.i4c.auxillary.Switches

Don't forget a newLine at the end.
Best Regards from Lower Bavaria
RBBT
http://www.robobuam.de/

CohesiveTechnology
Phidgetly
Posts: 15
Joined: Sat Jun 11, 2011 6:34 pm
Location: Keene, NH USA
Contact:

Re: Java errors in simple SBC2 program

Postby CohesiveTechnology » Thu Jun 23, 2011 1:27 pm

I am still struggling a bit. Calling the boards from my core works fine, but I want to get the SBC2 to control my IFK (0/0/4).

My setup is simple: SBC2 8/8/8 with one IFK 0/0/4 connected (at the moment).

Does my project path need to reflect my fully qualified package? (ie com.CohesiveTechnology.i4c.Switches needs to be on the SBC in projects "com/CohesiveTechnology/i4c/Switches"?

It feels like I just find my entry point into main().

Advice is appreciated.
DJF

David Falkenstein
Cohesive Technology - seamless is everything

RBBT
Phidgeteer!
Posts: 90
Joined: Sun Nov 15, 2009 2:16 pm
Location: Lower Bavaria (Germany)
Contact:

Re: Java errors in simple SBC2 program

Postby RBBT » Sat Jun 25, 2011 8:13 am

CohesiveTechnology wrote:
Does my project path need to reflect my fully qualified package? (ie com.CohesiveTechnology.i4c.Switches needs to be on the SBC in projects "com/CohesiveTechnology/i4c/Switches"?


Yes, but it's unusual to have a project as classpath structure on a target machine. You should jar the whole project.
Best Regards from Lower Bavaria
RBBT
http://www.robobuam.de/

CohesiveTechnology
Phidgetly
Posts: 15
Joined: Sat Jun 11, 2011 6:34 pm
Location: Keene, NH USA
Contact:

Re: Java errors in simple SBC2 program

Postby CohesiveTechnology » Thu Jun 30, 2011 7:20 am

I finally nailed it. Thank you both for your replies.
DJF

David Falkenstein
Cohesive Technology - seamless is everything


Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests