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

  • SEARCH
  • Home
  • 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 6715339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:36:10+00:00 2026-05-26T08:36:10+00:00

He, How to call from Java a Scala case class which has an implicit

  • 0

He,

How to call from Java a Scala case class which has an implicit paramter?

Scala:

object Loggable {
 case class RunUnit(val id : Integer) {
  override def toString() = id.toString()
 }
 case class Run(
  val id : Integer, val unit : RunUnit, val start : Long
 )(implicit db : DB) { ... }
}

Java:

public class JTest {
  public static void main(String[] args) {
    // works fine
    Loggable.RunUnit ru = new Loggable.RunUnit(4711);
    // how to add the implicit parameter???
    new Loggable.Run(new Integer(4711), ru, 0L);
  }
}

Thanks,

/nm

  • 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-05-26T08:36:11+00:00Added an answer on May 26, 2026 at 8:36 am

    You would have to provide the implicit explicitly. Try this:

    new Loggable.Run(new Integer(4711), ru, 0L, db);
    

    I tried to use javap to see what the signature are, and on a top level case class, there is simply an extra parameter to the constructor.

    Edit: using your code (with a dummy DB class):

    scala> :javap Loggable$Run
    [snip]
        public Loggable$Run(java.lang.Integer, Loggable$RunUnit, long, DB);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Yes I know I can call Java code from Scala; but that is pointless;
I would like to call the following java method from scala: protected final FilterKeyBindingBuilder
I am trying to call cleartool from an java application, but cleartool hangs even
Is it possible to call a COM API from Java (specifically the HP/Mercury Quality
I read that you could call JavaScript code from a Java Applet by calling
i am trying to call a navite method defined in c++ from java, the
I am using JNI to call my C++ function from Java. One of the
I need to call some PL/SQL procedures from my Java application. I can do
I need to call some methods in Wininet.dll from a Java program. I can
I'm trying to call a PostgreSQL stored procedure from a Java app; the procedure

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.