Getting Started - classpath issues

42 views
Skip to first unread message

Alex Cruice

unread,
Sep 30, 2015, 9:23:50 AM9/30/15
to ORMLite Users
Hello ORMLite Users,

I'm attempting to follow the details on the Getting Started page to introduce myself to ORMLite. I'm having great difficulty getting the files to even compile.

- I've downloaded both ormlite-jdbc-4.48.jar and ormlite-core-4.48.jar
- I've created Account.java and AccountApp.java based on the code examples (everything is in the same folder)
- I understand I need to use the classpath flag to tell javac where to look for the necessary classes

$ javac -cp .:./ormlite-core-4.48.jar:./ormlite-jdbc-4.48.jar Account.java
yields "cannot find symbol" errors for the DatabaseTable and DatabaseField annotations.

I've tried:
- various imports in Account.java (e.g.: import com.j256.ormlite.table.DatabaseTable; // yields error: package com.j256.ormlite.table does not exist)
- relative classpath references
- absolute classpath references
- -verbose flag to inspect the classpath
- all files in the same directory
- jar files in a different directory
- checking permissions of the jar files and enclosing folder (644 and 755 respectively)
- extracting the jar contents
- different versions of ORMLite
- *-sources.jar options of the jar files
- different versions of javac
- different machines
- different operating systems
- Googling every error message I encounter
- trawling StackOverflow
- trawling the support options mentioned on the ORMLite homepage (hence why I'm now posting here)

I can't figure out why I can't get this file to compile. I know it's probably some tiny detail I'm missing and I'm going to kick myself when it's discovered but right now I'm just stumped.
I can switch to another Java project using derby and compile with relative classpath references without a hitch. What on earth am I doing wrong with ORMLite?! I'm not the most experienced Java programmer, just what I've encountered while using it at university.

Running:
Mac OS X 10.9.5 (13F1112)
javac 1.8.0_60

Any help appreciated,
Alex C.

Daniel Melo

unread,
Sep 30, 2015, 10:06:54 PM9/30/15
to ormlit...@googlegroups.com
Alex,

Can you post the source code for Account.java?

Regards,

Daniel



--
You received this message because you are subscribed to the Google Groups "ORMLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ormlite-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Cruice

unread,
Sep 30, 2015, 10:36:40 PM9/30/15
to ORMLite Users
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable(tableName = "accounts")
public class Account {

  @DatabaseField(id = true)
    private String name;
  @DatabaseField
  private String password;

  public Account() {
    // ORMLite needs a no-arg constructor
  }

  public Account(String name, String password) {
    this.name = name;
    this.password = password;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }
}

Daniel,

It's been changed various ways as I've been trying to solve this, but that is it's current state.

Regards,
Alex.

Daniel Melo

unread,
Sep 30, 2015, 10:50:11 PM9/30/15
to ormlit...@googlegroups.com
Alex,

My environment is Windows 10, Oracle JDK 1.8.0_60. I was able to compile your class using the following steps:

1 - Created Account.java with your source code;
2 - Download ormlite-core-4.48.jar and ormlite-core-4.48.jar and placed them in the same directory of Account.jar
3 - Compiled with javac -cp *;. Account.java

As you are using MacOSX I would assume the command would be javac -cp *:. Account.java

I hope it helps,

Daniel

Alex Cruice

unread,
Sep 30, 2015, 11:39:29 PM9/30/15
to ORMLite Users
Daniel

It most certainly helped. I can confirm that this works.
Big facepalm moment when I realised what I was doing. Every compile attempt previous when I had used a wildcard, I'd failed to structure it properly or quote it.

$ javac -cp * Account.java   // fails
$ javac -cp *:. Account.java // works
$ javac -cp *: Account.java  // works
$ javac -cp "*" Account.java // works

I knew it was something simple, just a lack of bash fluency shining through.

Thank you kindly.

Regards,
Alex.

Daniel Melo

unread,
Oct 2, 2015, 10:04:24 PM10/2/15
to ormlit...@googlegroups.com
I am glad it helped. 

I suggest you adopting a build tool like Maven or Gradle. It will handle all classpath configuration for you.


Reply all
Reply to author
Forward
0 new messages