Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Sunday, August 8, 2021

Flutter: Unable to find bundled Java version

Let's say you try to run your flutter app in a simulator and failed.
When you run "flutter doctor", you get this message: "Unable to find bundled Java version".
What you need to do is to duplicate the Contents directory into a directory called jdk [1].
$ cd /Applications/Android\
$ mkdir jdk
$ cp -R Contents ./jdk/Contents

Saturday, January 15, 2011

How to run Java class file on Ubuntu

Let say you compile the following Java codes
public class hello {
    public static void main(String[] args) {
using the following command:
You will get a class file `hello.class`.

However, when you try to run the Java class file using
java hello

like you usually did on Windows, it won't run.
Exception in thread "main" java.lang.NoClassDefFoundError: hello Caused by: java.lang.ClassNotFoundException: hello at$ at Method) at at java.lang.ClassLoader.loadClass( at sun.misc.Launcher$AppClassLoader.loadClass( at java.lang.ClassLoader.loadClass( Could not find the main class: hello. Program will exit.
Actually, to run Java class file on Ubuntu, you need to always specify the classpath, using the `-cp` options.

As an example,
java -cp . hello

The `.` means the current working directory. In other words, you are telling Java to look for `hello class` in the same directory that you invoke the `java` command.

You can also add the current directory to the CLASSPATH, like this:
If you don't like to do that each time you want to run a Java class file, you can set the CLASSPATH permanently in /etc/environment or in ~/.profile.

Sunday, August 2, 2009

How to install Java on Ubuntu 9.04

To install Java support on Ubuntu, run this command in a Terminal:
sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin
You can also click here to test whether the JVM is working fine in your browser.