Results 1 to 19 of 19
  1. #1
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Question .java > .class conversion

    To be simple, I need to find a program or process of some sort that will convert a file with extension name of .java to .class. All attemps I have made to find a way have either come up empty or simply not worked.
    I already have a program that will take .class and convert it to .java, but for whatever reason, not the other way around.
    So I would greatly appreciate a fairly simple, or at least well explained way of converting .class > .java or a program that will do it for me.
    Thanks.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    The javac program will create a .class file from a .java file.
    Its called a compiler and most all programming languages have a program that does something like this.

    You can get the javac program in Sun's JDK download.

  3. #3
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    That is one of the fails I mentioned. In my searches I found out about JDK, so got 6.0. So far I have not figured out how to make it work however. I found a few explanations, but so far, I'm still rather lost on how to make it work due to the lack of a proper 'tutorial' through it I guess.

  4. #4
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Open command prompt type cd then where ever the file is located.

    for example: C:\ Documents and Setting>cd userName\so on and so on

    then type in javac and the filename

    for example: C:\ Documents and Setting\userName\so on and so on>javac myFileName.java
    My IP address is 127.0.0.1

  5. #5
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    I'm getting what I got each other time I tried, "'C:\Documents' is not recognized as an internal or external command, operable program or batch file".

  6. #6
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    no type in everything from cd on
    My IP address is 127.0.0.1

  7. #7
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    Did that too. Same results. Not sure what I'm doing wrong here, but obviously there is something.

  8. #8
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Untitled Document

    Then click on beginner

    Then click on your first java program

    then read
    My IP address is 127.0.0.1

  9. #9
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    ... I have to say I'm still lost. >_<
    I can't seem to get javac to do anything.
    There isn't anything specific I have to do to get JDK to work right is there? I read something about the environment variables, but so far that hasn't helped either.
    *sigh*
    Is there a program that I can just pull the .java file into and basically 'save' as a .class file? Thats pretty much what the program I have for .class > .java does.

  10. #10
    Join Date
    Jul 2008
    Posts
    33
    Rep Power
    0

    Default

    check your classpath if javac doesnt work in your console.
    :DMy community with sourcode and examples :D
    Java remote image server/client working proof of concept: uitstekendeaccu.nl/tmp/

  11. #11
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Engineeringserver.com View Post
    check your classpath if javac doesnt work in your console.
    This is really no help to me unless I know what the classpath SHOULD be. Which frankly, I don't.. :o

  12. #12
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    To show you current Environment variable settings:
    Open a console window and enter: SET
    copy the results and paste it here.
    To copy, click on icon in upper left of the console window, select edit and select Select all
    then again and select copy
    Then paste it somewhere and then copy it here

  13. #13
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    *Removed*

    And this gets what done..? :x
    Last edited by Fate_Remai; 11-10-2008 at 11:55 AM. Reason: Wished to remove certain info.

  14. #14
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    When you enter a command in a console, Windows must find the program before it can load the program and execute it. Windows uses the paths listed in the PATH variable to find command files.
    When you installed java you needed to add the path to the bin folder to the PATH variable.
    I see that the JDK variable in what you posted has the address to a bin folder for a JDK.
    You need to update your Environment variable PATH to include what is in JDK. Use Search for a full description of how to update Environment variables.

    Here's what is in my PATH variable:

    Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Sys tem32\Wbem;C:\Program Files\Java\jdk1.5.0_04\bin;C:\Perl\bin;C:\BatchFil es

  15. #15
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    Well that seems to allow javac to work. My remaining problem seems to be getting it to find the file. I understand the 'javac MyFileName.java' thing. I'm not fully sure how to make it find the file I want to convert from .java to .class.
    Perhaps it has something to do with my console opening and automatically having 'C:\Documents and Settings\Admin>' rather than simply 'C:\>'? (I don't recall how to reset this by the way)

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Making shortcut to start in java source folder

    Make a special shortcut for your desktop to start where your .java files are:

    Navigate to where the Command Prompt shortcut is
    Rightclick on it and select Copy
    Go to your desktop rightclick on it and select Paste.
    Rightclick on the shortcut just placed and select Properties
    Enter the path to your .java files in the Start In: field.
    Click Apply
    RC and rename to shortcut to remind you of where it goes or whatever

  17. #17
    Fate_Remai's Avatar
    Fate_Remai is offline Member
    Join Date
    Jul 2008
    Posts
    9
    Rep Power
    0

    Default

    Wahlah! It is now working and I can finally do what I have wanted to do. Thank you very much Norm.
    I'll be sure to keep this forum in mind if I have any further troubles. ;)

  18. #18
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Exclamation watch for unpredictable shell hooks

    Quote Originally Posted by Fate_Remai View Post
    ....I'll be sure to keep this forum in mind if I have any further troubles. ;)
    Yes, definitely - that is what this discussion group likes to practice on. Beware, I have noted that too often the machine wants to put C:\Documents and Settings\Owner\ in front of important information without telling you. I find that proprietary limits one to the twenty six letters of the iso-latin-1 ascii a-z and will cause things to disappear completly ( or seemingly so )

    The best approach I know of, the one I am using right now, is to put first work in C:\Documents and Settings\Owner\My Documents and then write programs directly in Java there. Right now I am placing the compiled class files in a directory different from the source files. I copy those manually to where I want them.

    In any approach, be totally patient. Frustration does not achieve forward study.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  19. #19
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    Somewhere you can change the default target directoryh for Windows programs to your own folder. I've never tried, but have often wished I had.

    I rarely put anything in the My Documents folder. I have 6 drive letters assigned and use D for work, E for data, F for backups, G for copies of stuff from old computers and H for backups for my wife and from the laptop.

Similar Threads

  1. Doc to Pdf conversion
    By praveen.kb in forum Advanced Java
    Replies: 2
    Last Post: 01-16-2009, 01:27 PM
  2. Text to XML conversion
    By tarandeep.singh in forum XML
    Replies: 1
    Last Post: 06-14-2008, 03:17 AM
  3. conversion of java .class files to .java files
    By kotturupraveen in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 01:58 PM
  4. binary conversion
    By thamizhisai in forum New To Java
    Replies: 3
    Last Post: 04-29-2008, 12:55 PM
  5. IDL to Java conversion using idltojava
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-07-2007, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •