Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9251035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:35:46+00:00 2026-06-18T10:35:46+00:00

For the first time in a while I’m doing java programming outside of Eclipse

  • 0

For the first time in a while I’m doing java programming outside of Eclipse (for coursera algo course) and I’m trying to use SBT for builds. SBT works fine (slow to start though) but I cannot figure out how to enable assertions. Neither of the following seem to work.

javaOptions += "-ea" // doesn't work
javaOptions in run += "-ea" // doesn't work either

build.sbt

// disable using the Scala version in output paths and artifacts
crossPaths := false

// Enable assertions?
javaOptions += "-ea" // doesn't work
//javaOptions in run += "-ea" // doesn't work either

organization := "me"

name := "me"

version := "1.0-SNAPSHOT"

// Use jars from parent dir. Normally jars are stuck in lib/
unmanagedJars in Compile += file("../stdlib.jar")

unmanagedJars in Compile += file("../algs4.jar")

QuickFind.java

import java.util.Arrays; // I hate java so much

public class QuickFind {
    public int[] id;

    public QuickFind (int N) {
        id = new int[N];
        int i;
        for (i = 0; i < N; i++) {
            id[i] = i;
        }
    }

    public boolean connected (int p, int q) {
        return id[p] == id[q];
    }

    public void union (int p, int q) {
        // Walk through array and make everything with id = p || q
        // equal to id p
        int pid = id[p];
        int qid = id[q];

        int i;
        for (i = 0; i < id.length; i++) {
            if (id[i] == qid) id[i] = pid;
        }
    }

    public static void main (String[] args) {
        StdOut.println("QuickFind"); // from stdlib.jar
        QuickFind uf = new QuickFind(4);
        uf.union(0,1);

        // Assert unions work
        StdOut.println("array=" + Arrays.toString(uf.id));
        assert uf.connected(0,1);
        assert uf.connected(0,2); // <---------------------this should fail
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:35:47+00:00Added an answer on June 18, 2026 at 10:35 am

    This link explains it. The short version is use the below in your build.sbt:

    // Enable assertions
    fork in run := true
    
    javaOptions in run += "-ea"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While using Aptana and Eclipse for the first time in my programming life for
I came across Side-by-side Assemblies for the first time today while trying to install
I'm doing some work in Actionscript 2.0 for the first time in a while
ok ... first time I'm trying my hand at node.js. installed it a while
This is my first time trying to use both ARC and Core Data. I
First time doing Python in a while, and I'm having trouble doing a simple
I need to use pure Javascript for the first time in a long while,
For the first time in years I've been doing some T-SQL programming in SQL
This is my first time trying out ZooKeeper and while I could easily set
I am getting an error while deploying code for the first time. I used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.