I am a beginner in mining algorithms and I have a general question regarding the mining using Java language.

Does it make sense to use Java to develop for example ETHASH algorithm (or any other) and is it going to be as such effective as C ?

I already found that it is possible to do mining with Java and OpenCL, for example here : is there a Java or C# library for mining bitcoins?

But still, I am confused, is it going to be slower? Or Java just need to transfer data/code to GPU and then it works the same as native C code? Or am I missing something? How is it working under the hook?

Thanks in advance for any response or reference.

  • Assuming you mean Java as in Oracle Java and not JavaScript? May 26, 2018 at 9:54
  • Yes, Oracle Java language.
    – rholovakha
    May 26, 2018 at 9:58
  • Thanks you shouldn't have to clarify that but these days I see so many people ask questions referring to js and calli g it Java. I mean if the co text is clear than I can see calling js Java for short but I've seen it where it can go either way and then I assume naturally Java and turns out they meant js, waisting everyone's time. May 26, 2018 at 11:04

1 Answer 1


Java (Oracle and not JavaScript) is typically one of two competing paradigms for enterprise servers. The other is windows, assuming that Java is always paired with some enterprise version of Linux. So though you can completely use Java on windows servers without any loss of utility or performance, in the setting that you were to use Java you would just likely use Linux as windows has a competing programing paradigm known as c#. Also the comparison here is rough and not meant to be lliteral 1 to 1 map of c# to Java.

That said the primary reason for Java is complete hardware abstraction and portability of programs. A side effect of this is easier scalability. New server hardware can come online and completely and automatically join existing server hardware in running Java.

Java is probably one of the most high level software languages there are. In that you can deal with primarily abstract computational notions with out dealing with often repetitive and frankly independent aspects of everyday computers in their present formats. Additionally this could be why Java has some following in academia. You can study the abstract computational problems instead of some standard publication which may go out of date. In theory some Java software will never be outdated or obsolete if correctly written.

Java as a trade off does have significant overhead. When you say c or c++, that doesn't necessarily describe it's performance as to some extent that is just a standard which describes the syntax of the language. What you may actually be thinking of is what it compiles to. Depending it can be portable executable or .exe for example or it can be microcontroller arm machine binary or a list of Opcode's ready to be read off by the processor.

Java does specify the performance because it only compiles to one thing. That is a set of codes which the Java virtual machine executes (which in turn is executed by the stuff c would produce). This is how Java gets its portability. The JVM acts as a socket or adapter from one interface to another. Therefore one person need develop the JVM for the particular machine and that's it. You can see it's high priority for Java to improve performance of its JVM's. But even still for example in c and low to hardware, you can switch out costly trig functions to rough approximation by multiplication of a constant. In for loops etc calling trig functions this might be permissible in c while rendering a Java application utterly impossible.

Finally as to mining, Java key aspect is scalability. Software in Java can easily and very neatly be written to detect say new network additions and start scheduling work for them. So you can take any computer and as long as it has a JVM, it is now part of the pool simply by starting the same Java app that everyone else is running. I'm not sure you can get this aspect as easily with c. This is partly because windows has a different philosophy on hardware OEMs partly motivated by profits and a business environment, however you can see the good it has done in its own right by the excellent diversity of windows PC hardware while still typically retaining top performance to alternatives.

Again. Though Java allows enterprise to easily gain the server power they need and minimizing headaches. Sometimes the headaches are necessary to learn but sometimes it's not what's wanted.

In any case if you model the reduction in performance due to JVM overhead, you would have to compare that to longer down time or time in bringing up new hardware. If it took you a week to get a new minor up on say windows in c, and you could of had it up in 5 miinutes on Linux distribution with Java JVM you may be losing money short term. If the mining hardware had short life span that too could improve the cause for Java. It's some what to iot and using o.s. or not. You may get better performance with your custom servo controller but if a raspberry pi gets it up and running with Linux in 1 percent of the time, realistically after only a few projects testing prototypes you begin to devalue the bare bones solution.

  • Thank you for so extended response. I would like to note that I have a good experience working with Java language (up to 10 years): just meant - I understand everything you described about scalability, adapter, endless etc. But I am very beginner in mining algorithms (combining with HW). What I need is actually develop mining desktop app. What I understood that Java does not have native support to execute code inside GPU, which means I need to use some kind of 'Adapter' - OpenCL. I don't see enough experience of using Java with mining, which confuses me. Even that DiabloMiner is not supported.
    – rholovakha
    May 26, 2018 at 11:47
  • Well than you can see with your experience that Java will obviously not prove competitive in mining, in those aspects. It is really an enterprise solution to web hosting/server. Today that is changing a little bit with aws, which pulls rug out from Java by using a VM representing a single machine across several machine. Aws isn't efficient if it's using a VM. this is the trade off for easy cross platform compatibility same with Java and a trade off of efficiency most large enterprise are frankly willing to go. May 27, 2018 at 4:13
  • With rise in aws it shows large and even medium and small size organizations are willing to for go performance and efficiency (cost) for simplicit. with Java bringing up new minors is as simple as acquiring nearly any kind of programmable computer at least capable of running the JVM. That is where the benefit will be. I won't get into what levels are required to beat or be profitable. May 27, 2018 at 4:18
  • So to abruptly answer your question, the total number of computer devices capable of running a JVM is larger than the total hardware specific devices to mine. So clearly Java in theory is a solution that works in theory, but probably may never exist in reality. May 27, 2018 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.