Setting up Cloud9 to compile and run Java?

I tried posting this request on Cloud9 forums, but since it is never published, I hope someone here can give me a hand. (The forum continues to state that my question is sent for consideration, but then never appears).

I can not get Java code to compile and run. I searched for this problem and read other posts in my limited forums, but I cannot collect it and run the simple Hello World! program. My .java name matches the class and the code is fine.

I tried putting my .java files in the following directories:

test/java/ test/src/ 

I just get the following:

 bash: src/HelloWorld.java: No such file or directory 

I tried this: http://www.programmingforliving.com/2014/09/java-coding-with-cloud9-ide.html

But I just get:

 Running HelloWorld.java Error: Could not find or load main class HelloWorld 

Any suggestions? Given that I'm essentially Java noob, I hope the solution is pretty simple.

+8
java ide compiler-errors cloud9-ide
source share
6 answers

If you don't embed your code, it's hard for you to say, but make sure your class and file name are called HelloWorld. Make sure your src folder is in your main workspace folder, so your file should be in /home/ubuntu/workspace/src/HelloWorld.java .

In addition, this documentation looks pretty similar to the blog you linked to, but still worth a look https://docs.c9.io/docs/custom-runners .

+4
source share

I think Codenvy is much better in java than Cloud9. It provides easy assembly and configuration start, code completion, sharing projects with permissions or factory (creates a clone of your project with one click in minutes). Take a look at the official java spring factory . This link opens a temporary (personal) java project, ready for coding, assembly and launch. In addition, Codenvy has a project wizard that has many types of projects, including a Java console application (uses maven).

+4
source share

Well, I decided to turn around with him and figure it out ... (then I saw that Brady Dowling published a link that explained in more detail what needs to be changed).

Anyway, I noticed a few things in Cloud9.

  • Even after making changes and saving, it still won’t compile correctly. I had to close the C9 session and go back. Then it will work.
  • After compiling and trying to run the program, it did not automatically select the Java runner that I made. Therefore, if you encounter problems, make sure Java is selected in the console (or whatever you called it).
  • You must compile and run separately. The view is annoying, but at least it works. Unlike C / C ++ in C9, it will not compile and run just by clicking "Run". If you do this, an error is generated indicating that .class does not exist. Just how to press F7 to build, then F5 starts up.

In any case, I took screenshots of what I had to change to make it work. In fact, only directories it searches for a .java file (right arrow) and the directory in which it searches / compiles a .class file (left arrow). Since I put .java and .class in the same directory (java), I just changed both to "java". In the links Brady and I posted, they used .bin (for .class) and src for (.java).

The first image is the Builder file (I called it javac), and the second is the Runner file (I called it Java).

BuilderRunner

In any case, I hope this helps someone. I really like the C9 and it is great for my newcomers at the moment. I like it when you can use different languages ​​to see what I like, without having to switch applications. Real-time preview of HTML / CSS as brackets is another huge plus for me.

Hi

+3
source share

As far as I understand, C9 workspaces do not come with jdk installed. But I always use the following commands:

  • Sudo apt-get update

(wait a while to complete the processing).

  1. sudo apt-get install default-jdk

(Then he will ask you to get some permission. Enter "Y")

And then it compiles and starts normally using the terminal.

+2
source share

Sometimes you also need to install a package to get javac.

Example:

sudo apt-get install openjdk-7-jdk

+1
source share

The java command is working correctly. You can java -version see that Ubuntu is working. You can also find the java binary and see that it is amd64. This is all you need to know to manually download jdk from Oracle.com, for example

 wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-i586.tar.gz tar xf jdk-8u92-linux-i586.tar.gz 

and jdk-1.8.0_92/bin/java(c) , jdk-1.8.0_92/bin/java(c) can be done! This allows you to compile java files.

0
source share

All Articles