What Java components do I need to use Clojure? - java

I'm setting up an Ubuntu VM to experiment with Clojure. In the Getting Started guide for Clojure, it shows running a java command. which java in my vm doesn't find anything.
I know nothing about Java. Tutorials for installing Java talk about the runtime environment, the SDK, etc.
What do I actually need in order to run Clojure?

Just the Runtime Environment
To run the REPL, all I needed was the Java Runtime Environment, which I installed with sudo apt-get install openjdk-7-jre.

Related

Downgrade from Java OpenJDK 64-Bit Server VM 1.8.0_292

Good morning, I have an application that works only with Java OpenJDK 64-Bit Server VM 1.8.0_292, however we are in the Java OpenJDK 64-Bit Server VM 1.8.0_312 version. How can I install it?
Go here: https://adoptium.net/releases.html?variant=openjdk8
download package
extract package
try calling it direclty (/new/path/jdk8/bin/java -version). This should now differ from calling the default java (java -version)
instead of calling the first java the systems finds (like java -Xmx500G -jar yourApp.jar), run your app via direct java path call: /new/path/jdk8/bin/java -Xmx500G -jar yourApp.jar
For Windows you can create .bat files, for linux you can create runnable bash scripts etc.
Oh, and a little side note: if that app is really only running under a certain revision version of java, it's probably really bad software...

The program 'jshell' is currently not installed when trying to run jshell on Ubuntu

I have downloaded and "manually" installed JDK 10 for Linux 64bit edition (for Ubuntu 16.04),
Oracle Java SE Development Kit
(note: I wanted to download the Java9 JDK but this is no longer supported and I was referred to the Java 10 SE Development kit instead).
When I try running jshell from a terminal window I get the following error,
The program 'jshell' is currently not installed. To run 'jshell'
please ask your administrator to install the package
'openjdk-9-jdk-headless' You will have to enable the component called
'universe'
I dont know why the message is asking me to install openjdk when I have installed the classic java version. When I run "which jshell" I dont get any details returned.
Can anyone help me get jshell installed and working ?
JShell is a development tool. You should download and install the Java Development Kit to run jshell, not just the Java Runtime Environment.
On Linux, and specificallly Ubuntu, development tools are not best installed via apt. The exception to prove the rule is RVM, which is installed via apt purely so that it will download ruby and ruby gems dynamically outside of apt.
For Java, the equivalent is SDKman, which is installed via curl. Once you have SDKman then you can install Java and other Java type tools.
SDKman in action:
thufir#dur:~$
thufir#dur:~$ sdk list java
================================================================================
Available Java Versions
================================================================================
12.ea.20-open
11.0.1-zulu
> * 11.0.1-open
10.0.2-zulu
10.0.2-open
9.0.7-zulu
9.0.4-open
* 8.0.192-zulu
8.0.191-oracle
7.0.201-zulu
6.0.119-zulu
1.0.0-rc-10-grl
1.0.0-rc-9-grl
1.0.0-rc-8-grl
================================================================================
+ - local version
* - installed
> - currently in use
================================================================================
thufir#dur:~$
Generally, umake, or Ubuntu Make, will install IDE or other development tools. Currently, umake is best installed as a snap.
The upshot is to first install SDKman, then snap, then use snap to install umake. Between umake and SDKman your tools should be up to date.
(Ruby uses a similar RVM, which inspired SDKman.)
I followed the tip given by Ernest Kiwele and others above and set-up my JAVA_HOME partly as described in
How to set JAVA_HOME in Linux for all users
but also by creating a sh script in my profile.d directory. Thank you for the help.
I dont feel completely comfortable with my solution since I have configured my Java using update-alternatives. I dont know why people advise to use update-alternatives to set the version of Java to use if the other depending variables aren't set-up at the same time.

Is there any way to run a Windows-based Eclipse with a Linux-based Java SDK?

I want to test my code against the (beta) IBM Java SDK 8.0, which will be a part of IBM Java products in future and support Java SE 8. The beta version is available for download from here, but it's only available for Linux on x86 (/ x86_64), and not Windows. But my development environment is Windows. Of course, I could run the Java SDK through Cygwin or equivalent, so it's possible to execute the binaries, but is there any easy way to trigger them from an Eclipse instance running on Windows?
I don't think you can do this. I would be surprised if it worked under Cygwin too.
The usual strategy for this type of problem is to create a Linux VM and test using that. There are free VM solutions around such as VirtualBox.

Cannot create project in Eclim

Hello good people of Stack Overflow, I have come with yet another question for your bountiful knowledge to answer. I am having a problem using eclim, a program that integrates the features of eclipse for java development into the Vim editor.
I am unable to create a project using the syntax defined on eclim.org, which is this vim command, ":ProjectCreate /path/to/dir -n java". I am typing this like this, ":ProjectCreate /home/username/Java -n java", where username is my username. The error I get is,
Java Model Exception: Java Model Status [Java does not exist]
while executing command (port: 9091): -command project_create -f "/home/username/Java" -n java
This led me to test if Java was installed on my system, using java -version. The output is,
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.1) (6b22-1.10.1-0ubuntu1)
OpenJDK Server VM (build 20.0-b11, mixed mode)
So I had Java installed, and I believe that is the OpenJDK version that is not used in my eclim installation. The version I specified is Java 1.6.0_24 of the sun Java JDK. That's beside the point though, as I do have Java installed.
So that's what led me to you. One last thing I would like to add though. I am using a headless server to run the eclim server in the background. This is through Xvfb, and is also detailed on eclim.org. I don't believe that is causing the problem, but I just thought it would be handy to throw in. As always, thanks for the help that will doubtless be provided.
I have done further testing and my original comment was not the correct reason. The real problem, was that I already had a directory at ~/Java. That tried to execute that directory for the project, which it could not do.

Java program runs smoothly in Netbeans but slowly in Eclipse and as an executable jar

A java program that does frequent swing/awt painting animation (but nothing more advanced than g.fillOval(...)) runs at a consistent 60fps in Netbeans, and at about 6fps when ran in Eclipse or executed as a jar file from a unix terminal. The program was developed in Netbeans and is run-of-the-mill desktop application (not webstart or japplet or ...). This is occurring in Ubuntu 10 with java 1.6. How is this possible?
$ java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
Set the default jvm to the sun version, and outputed the jvm used by netbeans and the unix terminal, which was the same for both:
java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.22/jre/lib/i386, java.vm.version=17.1-b03, java.vm.vendor=Sun Microsystems Inc.
However, this didn't make any difference as there is still a significant frame rate discrepancy. Is there some other factor that could be at play here?
One of possible reasons may be that NetBeans can use one JVM, and Eclipse and terminal "java" command can use another. Look into what platform NetBeans uses for your project, and compare it with Eclipse.
Also there can be something with arguments you passed to JVM. Check that too.
In Ubuntu there's a very handy utility. Try this:
sudo update-java-alternatives -s java-6-sun
in shell. It may output some errors...
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
That's only a problem with java plugin for Firefox. You may ignore this. If you have any other problem, than check which java you've got installed by issuing:
sudo update-java-alternatives -l
Or, you may use the interactive version:
sudo update-java-alternatives --config
(... this one I haven't tested).
If for any reason You don't have Sun's JDK listed post a comment.
EDIT
Are you using hardware acceleration? Try adding this JVM property:
-Dsun.java2d.opengl=True
To see details you might also use:
-Dsun.java2d.trace=log
Consult OpenGL acc for more details.

Categories