Java virtual machine

Discussion in 'Training & Development' started by zxspectrum, Oct 22, 2009.

  1. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    2,092
    216
    244
    Started reading a book claaed headfirst java, and im on my first attempt compiling code. Ive typed everything in correctly and i have all the tools that the book tells me i need. I next have to run the Javac application but i cant seem to get it running so im stuck???

    Does anyone knoe where this will be, do i access it through command prompt, or do i need to locate it and create a shortcut??? any help is useful

    Ed
     
    Certifications: BSc computing and information systems
    WIP: 70-680
  2. dmarsh
    Honorary Member 500 Likes Award

    dmarsh Petabyte Poster

    4,305
    503
    259
    You need to set up your PATH environment variable and your JAVA_HOME environment variable.

    On windows this is under Control Panel -> System -> Environment Variables

    Or type <windows key + pause/break> then System Settings -> Environment variables

    Then you can use a command prompt and run binary executables that are in your path.

    Otherwise you must be in the directory of the executable to run it, this is standard command line stuff.

    Theres various guides online, just google a bit for Java, JDK, PATH, JAVA_HOME, setup etc.


    Again things like CLI / Shells, Processes, Directory structures, File names, Environment variables should be covered in Computing 101 on your degree course.
     
    Last edited: Oct 22, 2009
  3. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    2,092
    216
    244
    Thanks for the tips there, Dmarsh. ive done everything and set the path etc, im im positive ive done it right. now in the bin section of where java stuff is located there are more of the files that were there before.i had about 10 before and now i have about 40 'things' .

    When i say 'things' they are like little command promptys, when i run them or double click a command prompt like screen quickly pops up then quickly dissappears, so im getting the impression i should leave well alone .

    The only reason i was trying them is because i i couldnt get the applet window openm that i wanted. Do i get that up and running through command prompt itself???

    As for learning command line code in our first year, that didnt happen and as for us beiong chucked in the deep end on this java course im not happy. The last bit of coding i did was visual basica which you also helped me out on, and were getting the same types of responses when we ask a question, either look at the slides or read a book, which to me is not teaching. When i say questions i dont mean a general one, mine will be specific, and they say you have to work this out for yourself, some things you can and there are some things you cant, i dunno , maybe its me, and java we shouldnt mix lol

    ED
     
    Certifications: BSc computing and information systems
    WIP: 70-680
  4. dmarsh
    Honorary Member 500 Likes Award

    dmarsh Petabyte Poster

    4,305
    503
    259
    Well read up on the command line and batch files in windows, all good stuff to know.

    Once a program is on your path you can execute it from anywhere, so once the JDK is on the PATH, you can execute all the JDK tools regardless of the present working directory (PWD) in your command prompt (CMD).

    Use javac to compile a java source file eg example.java into a class file example.class.

    Things get slightly more complex with multiple files and basically you have to ensure you have a valid Classspath.

    Visual Basic hides a LOT of complexity that exists in all programming environments from you very well, its probably a little too easy to teach true programming fundamentals, non programmers can produce working stuff without even knowing why.

    Once you have a class or set of class files you can launch then using java <startclass>.

    The java executable is the way to launch a command line version of the JVM.

    If you are unsure of any command line executable try <command> -? from the command line.

    eg java -?

    (Sometimes the switches differ and are /?, -h, -help, but you get the general idea.)

    Heres the sorta stuff I'd expect your uni to tell you :-

    http://www.cs.princeton.edu/introcs/15inout/windows-cmd.html

    failing that use a good book and the internet !

    Shortcuts are just like windows GUI versions of symbolic links, they are not really required from a CLI perspective, they just make things easier for the point and click crowd.

    Theres lots of possibilities, old books used to use applets a lot which need a browser or applet sandbox to run, all about grokking the information you need to get things working.
     
    Last edited: Oct 22, 2009
  5. soundian

    soundian Gigabyte Poster

    1,460
    71
    107
    You should run the compiled code in a command prompt. Those 'things' are command prompts but since you didn't execute the program from the command prompt the command prompt gets closed as soon as they're finished.
    Guess who's made the same mistake before? :oops:
     
    Certifications: A+, N+,MCDST,MCTS(680), MCP(270, 271, 272), ITILv3F, CCENT
    WIP: Knuckling down at my new job
  6. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    2,092
    216
    244
    I am trying to run them in a command prompt but im having no luck here. Im using notepad and the texte is all correct. Now command prompt doesnt have a compile button, so im guessing i do this through the Javac bit of the java stuff. To make it easier ive put it on the desktop as a shortcut, but im still not able to get that blooming window opened for more than a blink of an eye.

    I may need puppy walking onm this, with the command line stuff im not that into that stuff, tho maybe i should be, but because i need to learn the basicas of java for coursework im going to stick with this. Any more help would be appreciated

    Ed
     
    Certifications: BSc computing and information systems
    WIP: 70-680
  7. soundian

    soundian Gigabyte Poster

    1,460
    71
    107
    Certifications: A+, N+,MCDST,MCTS(680), MCP(270, 271, 272), ITILv3F, CCENT
    WIP: Knuckling down at my new job
  8. dmarsh
    Honorary Member 500 Likes Award

    dmarsh Petabyte Poster

    4,305
    503
    259
    Forget about the shortcuts, open a command prompt and type the commands into it, its really quite simple in reality.

    If you want to get a Computer Science degree or become a programmer you need to be comfortable at the command prompt.

    Soundians guide looks good, also look at the other links posted and READ them ! RTFM !

    My page had these links on command line :-

    http://www.cs.princeton.edu/introcs/15inout/msdos.html
    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
    http://www.amset.info/windows/dosprompt.asp
    etc

    As with everything on computers internet will have loads of info.

    As already mentioned if you run a command designed for the CMD from a shortcut it will run to completion in a spawned CMD process and then on completion the CMD process will be killed also. This is not helpful as the output from the command would have been in a window attached to that process which will now have dissappeared when the process terminated. The way round this is to manually open a command window and keep it open and manually enter commands into it, you can then see the output and interact by issuing other commands. This is what soundian was getting at. You probably also want to turn on the quick edit mode and alter the window buffer size etc while you're at it.
     
    Last edited: Oct 22, 2009
  9. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    2,092
    216
    244
    Guys, cheers for the advice and links, im going to leave this topic till tomorrow nowe and get my intranet security module out of the way, thats easier and plus irt will stop my heasd exploding. Although ill be cracking on with it again tomorrow after ive been the hospital, and then for the rest of the weekend, which should produce some results

    Cant wait till some sinks in, the guides you hjave put up there look decenmt as well, so thanks again

    Ed
     
    Certifications: BSc computing and information systems
    WIP: 70-680
  10. r.h.lee

    r.h.lee Gigabyte Poster

    1,011
    52
    105
    zxspectrum,

    Are you using a Windows OS?
     
    Certifications: MCSE, MCP+I, MCP, CCNA, A+
    WIP: CCDA
  11. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    2,092
    216
    244
    Yes im using Vista at the mo. Why??? do you suggest using something else operating system wise??

    Im also using netbeans as its what we have been told to by uni. The programming stuff the tutoe gives us is straight forward, its just shell miss bit out on purpose and expect us to get it straight away. That would be like me saying to someonn who knows nothing about cars, ok your engines stopped wotking, why???

    I know im meant to learn for myself but i think they are going about it the wrong way, the way i see it, you give people the basics then build on that, or is that just me .

    Ed
     
    Certifications: BSc computing and information systems
    WIP: 70-680
  12. r.h.lee

    r.h.lee Gigabyte Poster

    1,011
    52
    105
    zxspectrum,

    Try installing a program called "Textpad."

    http://www.textpad.com/
     
    Certifications: MCSE, MCP+I, MCP, CCNA, A+
    WIP: CCDA

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.