Java in Linux?

JC0133

Senior member
Nov 2, 2010
201
1
76
I want to start writing Java code in Linux. I am just not sure how or where to get a free version of Linux? Also not sure how to set up the Java environment in Linux to write the code.

Can anybody help me out here??

So far I have been writing my Java code Eclipse on Windows.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
You can use Eclipse in Linux too. Eclipse was written in Java after all. :p
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Go to https://www.virtualbox.org/ and grab a copy of VirtualBox. Get Ubuntu 11.10 from http://www.ubuntu.com/ and burn the ISO onto a dvd. Now create a new VM and set it to boot off the dvd drive, restart it, and install Ubuntu. Note that I have no particular reason for recommending Ubuntu. You could use Debian, or something else. It's up to you. Google around and you'll find plenty of info on various distros.

Once you boot into Ubuntu you can install everything you need either from the command line using aptitude (i.e. ~$/apt-get install "whatever") or you can open the Ubuntu software center from the launcher bar and search for packages there.

You can easily Google up specific instructions for the following, but anyway install Java (1.6 JDK and JRE), Eclipse, and maybe MySQL or some other database. That's pretty much it. I set up an Ubuntu VM for Python/Django/Android development the other night in maybe an hour.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
Do you need to go through the hassle of burning a DVD? I assume it can use a mounted disc (with Daemon Tools, etc.) or possibly even boot from an ISO (not sure about the latter).
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
On a Linux host, VirtualBox will mount an ISO from a file. I imagine it would in Windows too.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Yeah good point, that'll work too. I usually burn them just so that I have them around if I need something to boot off, so I didn't think about mounting the iso.
 

N4g4rok

Senior member
Sep 21, 2011
285
0
0
If you decide to try and run it from the terminal, You'll just use the command corresponding to the editor you're using. for example, i use Vim, so the command is 'vi filename.java'

Compile with 'javac filename.java'

run with 'java filename'

Have fun.
 

beginner99

Diamond Member
Jun 2, 2009
5,320
1,768
136
I set up an Ubuntu VM for Python/Django/Android development the other night in maybe an hour.

Maybe If you done it couple times before or are a linux expert in general. Recently tried it and had tons of issues concerning virtual box. problem is getting the full screen resolution. Simply said full screen did not work properly, only using crappy resolution and evening getting reasonable resolution in windowed mode was a hassle (if you have never done it before).

Installing netbeans and java was rather easy but then also getting maven and mercurial to work with it as in Windows, I stopped there. Lost patience also knowing working with crappy resolution was not worth the hassle.

Just posting this as a warning.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Maybe If you done it couple times before or are a linux expert in general. Recently tried it and had tons of issues concerning virtual box. problem is getting the full screen resolution. Simply said full screen did not work properly, only using crappy resolution and evening getting reasonable resolution in windowed mode was a hassle (if you have never done it before).

Installing netbeans and java was rather easy but then also getting maven and mercurial to work with it as in Windows, I stopped there. Lost patience also knowing working with crappy resolution was not worth the hassle.

Just posting this as a warning.

Yeah well, that's Linux for you. You have to work a little harder. In the case of VirtualBox and screen resolutions, however, all you need to do is download and install the Guest Extensions, and VB will take care of setting the screen resolution when you resize the window.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
If you decide to try and run it from the terminal, You'll just use the command corresponding to the editor you're using. for example, i use Vim, so the command is 'vi filename.java'

Compile with 'javac filename.java'

run with 'java filename'

Have fun.

I've had some weird times with trying to run java classes manually. Attempting to run them like you describe would never work. I had to go out to the base source directory and run them like this...

"java [-c if you need to specify the classpath] com.package.name.ClassName"
 

Fandango21

Junior Member
Feb 8, 2011
23
0
0
Try reading up on the documentation before you down VirtualBox. It's great and does have Guest Additions like Markbnj mentioned that will fix screen resolution, mouse capture problems just fine. I've even set up VirtualBox to run off of my NAS drive with iSCSI so it has some cool features for being free. Its also been really reliable. It was overwhelming for me too at first, I'm a beginner myself, but if you get past the frustrating parts and ask people for help too when you need it, it turns out that you can do some really cool things.

Also, as for Eclipse, I'd recommend downloading the most recent version from http://www.eclipse.org/ because I had some problems with the one in Ubuntu software center. I think it's probably just an older version because when i got the one from eclipse.org I had no problems.
 
Last edited:

beginner99

Diamond Member
Jun 2, 2009
5,320
1,768
136
Yeah well, that's Linux for you. You have to work a little harder. In the case of VirtualBox and screen resolutions, however, all you need to do is download and install the Guest Extensions, and VB will take care of setting the screen resolution when you resize the window.

Supposedly as I installed them. However it did not work correctly. Plus virtual box somehow borked my network as I wasn't' able to access my shares on that computer anymore and the magical reappeared just after removing it. Anyway it's OT and more an issue of VirtualBox and not linux.

Just wanted to point out that it might not turn out to work as smoothly as one would imagine.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
VirtualBox adds its own network adapter "thing", which can sometimes be a bit troublesome until you restart. I didn't have any trouble with it the last time I installed the software though.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Running code in Eclipse on Linux is basically the exact same experience you have now. Google around for "install java on Ubuntu" and you then install Eclipse. You should be fairly familiar with everything at this point.
 

N4g4rok

Senior member
Sep 21, 2011
285
0
0
I've had some weird times with trying to run java classes manually. Attempting to run them like you describe would never work. I had to go out to the base source directory and run them like this...

"java [-c if you need to specify the classpath] com.package.name.ClassName"

You don't run the .class file manually. Rather, you run something like a makefile generated from compiling the java file. 'java filename' produces the same results that your method does.