LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-20-2013, 03:36 PM   #1
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Rep: Reputation: Disabled
non-gui Java Editor/Compiler


Hi,I have a minecraft server 99.34.224.29:25565. (all you minecraft buddies are welcomed to visit!) but I have this problem. Sometimes I need to edit .class files remotely because I never have time at home to maintain the server.

SO that raises a question.... is there a java compiler/editor out there that will work in a ssh environment? I use ssh to login the ssh server to access my minecraft files. Is there a java compiler/editor that works in text mode? I Only have to make minor changes so it doesn't have to be with all bells and whistles...just save a few chars.

I spent a hour looking but can't find one...maybe it doesn't exist since Java was conceived during gui times.

Can you help? java text editor anyone?

 
Old 08-20-2013, 06:06 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
vim, nano, the list goes on and on and on.


I love vim because I know it and it has syntax highlighting for hundreds of languages including Java. Vim should be installed out of the box.
 
Old 08-20-2013, 06:44 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
The java compiler comes with the JDK, it is CLI only anyways, so no need for an extra one.
All you need besides that is a simple text editor (Vi(m), Emacs, nano, joe, literally dozens of others).
 
Old 08-20-2013, 07:19 PM   #4
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
vim doesn't work

Thanks but Vim gives me this...

screen full of codes and words ..machine language.

Can JDK open a .class file in SSH session? (no gui allowed)
if it can, do you know where I can get just the JDK editor?
what would the command line be? JDK <Filename.class> ?




Thanks
Attached Thumbnails
Click image for larger version

Name:	vim.gif
Views:	35
Size:	51.8 KB
ID:	13237  

Last edited by escolom; 08-20-2013 at 07:21 PM.
 
Old 08-20-2013, 07:27 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by escolom View Post
Thanks but Vim gives me this...

screen full of codes and words ..machine language.

Can JDK open a .class file in SSH session? (no gui allowed)
if it can, do you know where I can get just the JDK editor?
what would the command line be? JDK <Filename.class> ?

Thanks
I am not a java expert, but I think the .class files are the compiled java bytecode.

What you want to edit is the uncompiled source, usually .java files of the same name I think.
 
Old 08-20-2013, 07:33 PM   #6
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
Java editor

astrogeek,

those files are the .YML files in minecraft.
those are txt files so vim works fine. I wanted to look at
the .class files since I am trying to teach my self and kid Java

I no expert either but I know we have to compile the files.
something I want to learn. I might just use eclipse since its
gui only, I will be limited to doing my edits on the server only
and not remotely.
I don't think a .class editor exist for SSH..something we can use
in a putty session.

Thanks

Last edited by escolom; 08-20-2013 at 07:34 PM.
 
Old 08-20-2013, 07:35 PM   #7
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
But my point was that the .class files are going to look like that in any editor (other than a hex editor which may format them better), so you are not going to be able to learn java by looking at the contents of the .class files.

In other words, the .class files are already compiled.
 
Old 08-20-2013, 08:11 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
If you want to open and edit the .class files, you can still do that with vim and xxd.

xxd is a bi-directional binary/hex converter that ships with vim.

To use it, open the file in vim (as in your screenshot above), then:

Code:
:%!xxd
That will give you an editable hex representation of the compiled bytecode, like this:

Code:
0000000: cafe babe 0000 0031 0028 0a00 0c00 140a  .......1.(......
0000010: 000b 0015 0a00 0c00 160a 000b 0017 0700  ................
0000020: 180a 0005 0019 0a00 0b00 1a07 001b 0a00  ................
0000030: 0800 1c0a 000b 001d 0700 1e07 001f 0100  ................
0000040: 0d4d 6f75 7365 4c69 7374 656e 6572 0100  .MouseListener..
0000050: 0c49 6e6e 6572 436c 6173 7365 7301 0006  .InnerClasses...
0000060: 3c69 6e69 743e 0100 0328 2956 0100 0443  <init>...()V...C
0000070: 6f64 6501 0015 284c 6a61 7661 2f6c 616e  ode...(Ljava/lan
0000080: 672f 5374 7269 6e67 3b29 5601 000a 696e  g/String;)V...in
0000090: 6974 6961 6c69 7a65 0c00 0f00 100c 0013  itialize........
00000a0: 0010 0c00 0f00 120c 0020 0021 0100 0f6a  ......... .!...j
00000b0: 6176 612f 6177 742f 496e 7365 7473 0c00  ava/awt/Insets..
00000c0: 0f00 220c 0023 0024 0100 3f6f 7267 2f61  .."..#.$..?org/a
00000d0: 7061 6368 652f 6261 7469 6b2f 7574 696c  pache/batik/util
00000e0: 2f67 7569 2f72 6573 6f75 7263 652f 4a54  /gui/resource/JT
00000f0: 6f6f 6c62 6172 4275 7474 6f6e 244d 6f75  oolbarButton$Mou
0000100: 7365 4c69 7374 656e 6572 0c00 0f00 250c  seListener....%.
0000110: 0026 0027 0100 316f 7267 2f61 7061 6368  .&.'..1org/apach
...
To reconvert to binary and save:

Code:
:%xxd -r
CAUTION: If you save to the same file without reconverting to binary your original file will be overwritten! Also, editing hex code can easily break the original compiled codes in bad ways, so always work from a copy of the original and keep the original safe and unchanged.

Good luck!
 
Old 08-20-2013, 09:16 PM   #9
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
java

Astrogeek,

I understand now thanks. before files become .class files they have to be created as .java files in txt format than compiled with java compiler.. think it is javac.

Thats a neat trick with Vim.. I have to speak hex if i really got desperate to make changes

I am trying Jedit now.. but It isn't opening the .class files guess because they are compiled.
hey, I m learning now

so what would you recommend to start writing/compiling .java files to .class?
The moderator said JDK comes with it. I think he means openJDK I have 6 and 7 but my
javac file has broken link so I can't run the compiler. I am assuming trying to use Jedit, it claims to be a programmers editor..... It didn't like the class file tho something about utf-8

I am going to enroll in java classes at the local college.

*cheers*



thank you.

Last edited by escolom; 08-20-2013 at 09:18 PM.
 
Old 08-20-2013, 09:25 PM   #10
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
Author: Kevin Burton, Andre Kaplan, Dirk Moebius Released: 9 May 2007 The JavaInsight plugin adds an action to the file system browser that lets you decompile selected Java classes using the Jode decompiler. Furthermore it adds some actions to view selected classes in disassembled form, either BCEL or Jasmin output.

ah 2007!! too old! it has a java plugin but it will not download cuz its ancient!
 
Old 08-20-2013, 09:34 PM   #11
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by escolom View Post
Astrogeek,

I understand now thanks. before files become .class files they have to be created as .java files in txt format than compiled with java compiler.. think it is javac.
Great! Yea, I thought you might have been expecting the class files to be text, they are not.

To be honest, the only reason I spotted it is that my son is teaching me how to find my way around one of his java projects this week, so I had .java, .class, .jar on the brain already!

Yes, the java compiler is javac. On my Slackware system with Oracle java it is /usr/lib/java/bin/javac, not sure where it would be on another system or with OpenJDK. Type whereis javac and see what it says. You might also need to check your CLASSPATH environment variable.

Quote:
Originally Posted by escolom View Post
Thats a neat trick with Vim.. I have to speak hex if i really got desperate to make changes

I am trying Jedit now.. but It isn't opening the .class files guess because they are compiled.
hey, I m learning now
I used to do a LOT in machine code and assembler and edited hex files with one hand tied behind my back! But not so much any more. Vim is my editor of choice, but you might also have hex editor called bpe on your system. Try man bpe or bpe --help.

But with jave there is not much to be gained by that unless you already know the source inside and out.

Quote:
Originally Posted by escolom View Post

so what would you recommend to start writing/compiling .java files to .class?
The moderator said JDK comes with it. I think he means openJDK I have 6 and 7 but my
javac file has broken link so I can't run the compiler. I am assuming trying to use Jedit, it claims to be a programmers editor..... It didn't like the class file tho something about utf-8

I am going to enroll in java classes at the local college.

*cheers*

thank you.
We do all our development using vi (vim) as the editor, not much on GUI tools.

I think the only thing that you need is to find how to invoke the javac compiler on your system and take it from there.

As I said, my son is the java expert here, more like magician, but he is all self taught and uses only vi, jdk and the GNU/Linux tools - great stuff!

Good luck!
 
Old 08-20-2013, 09:39 PM   #12
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by escolom View Post
Author: Kevin Burton, Andre Kaplan, Dirk Moebius Released: 9 May 2007 The JavaInsight plugin adds an action to the file system browser that lets you decompile selected Java classes using the Jode decompiler. Furthermore it adds some actions to view selected classes in disassembled form, either BCEL or Jasmin output.

ah 2007!! too old! it has a java plugin but it will not download cuz its ancient!
I don't have a favorite java book, but I am sure there are many!

But in my opinion you should try to not get hung up on all the GUI tools, plugins, browsers, etc... they are a distraction and keep you from learning the language.

All you need is a plain text editor and the java compiler, and a little time to play with it. Once you see how it goes from text to bytecode by way of the compiler a whole new world will open for you!
 
Old 08-21-2013, 10:57 AM   #13
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
Astrogeek,

You and your kid inspire me man! I should hire him to do my java stuff for minecraft server. Oh, that wasn't a book it was Jedit about page. Jedit apparently comes with Debian 7 distro, i was just pointing out its ancient. all the editing in Vim sounds perfect for ssh access, I just don't have the skill you have..both hands here

Thanks for the advice about staying away from the java plugins and writing code in txt editor...I can't tell you how many times people have given me that advise.
my javac is located in /usr/lib/java/bin/javac but it says it has a 'broken link'. I had some problems installing Java so I had to use openjdk. Java is running because minecraft runs but when I run javac at terminal its as if the file isn't out there

-bash: javac: command not found

I am not sure what compiler openjdk uses, i will try to find out and post it here.

thanks for all your advise. I am trying to get my 15yr old kid interested in programming. (hence the minecraft server) Glad you were successful with yours.
 
Old 08-21-2013, 01:39 PM   #14
escolom
Member
 
Registered: Apr 2012
Location: San Francisco, cA
Distribution: Ubunto 12.04/Debian 7
Posts: 57

Original Poster
Rep: Reputation: Disabled
Last post.

I was able to solve the java compiler (javac) problem
with a simple sudo apt-get install openjdk-7-jdk


Also found a great program to teach kids Java.
I am using it for myself since I know very little

http://www.greenfoot.org/download/fi...enfoot-230.deb
 
Old 08-21-2013, 02:43 PM   #15
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Glad you got the javac working!

I hope your kid latches onto programming - I can't imagine anyone not doing so, but especially younger people.

When my son was 12 he took an interest in some of my projects, so I took him on a business trip to a customer site with a large computer center, some unique technology and a lot of friendly people.

I started him with php so that he could write code and see the immediate effect, effective both from a shell or with a browser UI. He devoured it so we got him Stroustroup's C++ books, K&R, a shelf full of O'Reilly and others, and his own computer(s)...

Somewhere in there he taught himself java, probably because it was a language I had never learned, and has written a couple of full featured java applications, and is now trying to explain one of them to my tired old brain.

He is now 26 and works as a programmer and system admin in his own right, among other things!

Good luck to you and your kid!

Last edited by astrogeek; 08-21-2013 at 02:45 PM. Reason: typos
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiler + editor cyb3rdawn Programming 3 06-15-2007 11:09 AM
C compiler/editor GUI paul_mat Linux - Software 3 02-06-2006 10:49 AM
C++ Editor/Compiler kerryblue19 Linux - Software 4 02-21-2005 07:22 PM
Help finding a Java editor/compiler MojoRising Programming 10 12-01-2004 09:16 PM
Java GUI Compiler/Editor Half_Elf Programming 7 09-13-2002 05:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration