CrazyEngineers
  • Java Help! Unable To Run Java Programs.

    manishks

    Member

    Updated: Oct 27, 2024
    Views: 1.0K
    hello friends,
    i have tried installing java many times but still i have not been able to run java programs😔😭 .
    i have changed path in environment variable and i suppose its correct. i am new to java programming language and so dont know how to start.
    i wrote a simple hello program and gave its name hello.java
    what i dont understand is that a class file is always executed and run( correct me if i am wrong) so do we need to create a a class file also.
    i just dont know how to execute the program and i have spent so many days doing these silly things. i could have learnt so many things till now 😔.

    guys help me out. please tell me the complete procedure of how to use command prompt to run java files. what should be the path and class path variable. how to use netbeans for executing java programs.

    i desperately need help in this😭😭 !!!😀


    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • younus786

    MemberApr 20, 2012

    Hi dude,
    First you need to install the correct jdk version.
    This are the steps you need to follow
    1.Install the correct jdk version either 1.6 or 1.7
    2.Check whether the correct folder of java is created in the folder program files in C drive or whatever your preferable drive.
    3.set path in command prompt as ,type this command exactly same in the cmd
    c:>path=C:\Program Files\Java\jdk1.6.0_01\bin;.;
    4.once this command get executed now type another command in cmd as
    c:>javac
    5. if you have correctly installed the java then following java commands will appear in cmd
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are u
    sed
    -classpath <path> Specify where to find user class files
    -cp <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release

    -target <release> Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system
    6.if these command s then you have correctly installed the java software
    7.Now move to your corresponding folder where you have save the java programs and execute it directly in cmd for example
    c:>javac Hello.java
    c:>java Hello
    8.Add the same environmental variable
    Enjoy.....
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 20, 2012

    C:\java programs>javac myfirstapp.java
    myfirstapp.java:2: cannot find symbol
    symbol : class string
    location: class myfirstapp
    public static void main(string[] args) {
    ^
    myfirstapp.java:3: package system does not exist
    system.out.print("i rule!");
    ^
    2 errors
    i am getting this error whenever i compile the program.
    i have installed java jdk correctly.
    also in my case jdk file is named as jdk1.6.0_02 hence i have set the path variables accordingly.
    please someone help me remove those errors.😔😔
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 20, 2012

    Path>.... C:\Program Files\Java\jdk1.6.0_02\bin;
    Classpath>... .;C:\Program Files\Java\jdk1.6.0_02\jre\bin;

    is anything wrong in above two???
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberApr 20, 2012

    Its like wining world cup to run first java program on your own😀
    I suppose you know how to set environment variables:
    add path variable in system variables. make sure it
    Capture11111

    Open command prompt:
    type javac and hit enter. if it is not showing bad command then you are set.
    write java program. Got path of your program and compile by:
    javac <programName>.java.
    after copiling you will see class file in same directory will be created.
    run by:
    java <programName> without any extension.

    If nothing helps do not frustrate, This all setting path and classpath sometimes sucks.
    just download Eclipse :#-Link-Snipped-#
    Create new project and then click on src and create new class.
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberApr 20, 2012

    musicfreakmandy
    Path>.... C:\Program Files\Java\jdk1.6.0_02\bin;
    Classpath>... .;C:\Program Files\Java\jdk1.6.0_02\jre\bin;

    is anything wrong in above two???
    yes,
    sometimes caps doesn't work. set by using path and classpath. or set only path.
    logoff machine and log in again. it should work.
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 20, 2012

    thanx ianoop 😀
    can i use netbeans instead of eclipse??????
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberApr 20, 2012

    sure you can .. only thing is Eclipse is lighter and simple to use.
    but even if you are making programs using eclipse. You should know and have some experience with running some java program using dos prompt and notepad.
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 20, 2012

    YES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    😁😁😁😁
    FOR THE FIRST TIME I HAVE SUCCESSFULLY COMPILED A JAVA PROGRAM!!!!!!!😎😎😎😁

    FINALLY!!!!

    THANX ianoop and younus786.👍👍
    thank you guys thank you for your help!!!!!!😀😀😀


    proud to be a cean!!!
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 20, 2012

    I would like to share what mistake i was doing!!!!


    in system.out.print 's' should be in capital similarly in strings also 's' should be in capital.
    for this silly mistake i wasnt getting the output and i changed path class path so many times..i reinstalled java jdk so many times!!!!!!!😛😛😁😁😁


    but i got the output at last!!!!!!😁😁

    Are you sure? This action cannot be undone.
    Cancel
  • yanivx

    MemberApr 22, 2012

    musicfreakmandy
    I would like to share what mistake i was doing!!!!


    in system.out.print 's' should be in capital similarly in strings also 's' should be in capital.
    for this silly mistake i wasnt getting the output and i changed path class path so many times..i reinstalled java jdk so many times!!!!!!!😛😛😁😁😁


    but i got the output at last!!!!!!😁😁


    Making a mistake is not Crime,Not learning from your mistakes is indeed crime i also faced a similar problem i set the path and then compiled and was really happy to see a .class file generated 😀
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 22, 2012

    yanivx
    Making a mistake is not Crime,Not learning from your mistakes is indeed crime i also faced a similar problem i set the path and then compiled and was really happy to see a .class file generated 😀
    Ya even i was very happy 😀
    Have you done any project using java language? ?
    Are you sure? This action cannot be undone.
    Cancel
  • younus786

    MemberApr 22, 2012

    Hi , guys if you want any help in doing java projects please repl me your queries.
    I m an scjp aspirant try to help your queries as much as possible
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 22, 2012

    Sure! We can discuss java concepts and projects here. It will surely help in clearing doubts! And also it will make java learning more fun! 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberApr 22, 2012

    That's a very common mistake we used to do in the initial stage 😀

    This is the thread started by our old CEan - Shalini for Java freshers/ learners. Hope this thread helps you to start initially well-> #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 22, 2012

    Thanks for the link sada. 😀 it will be really helpful. 😀
    Are you sure? This action cannot be undone.
    Cancel
  • yanivx

    MemberApr 23, 2012

    musicfreakmandy
    Ya even i was very happy 😀
    Have you done any project using java language? ?
    yes brother i am working in TCS and in Java domain and on a project of Telecom Inventory system using java.
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 23, 2012

    yanivx
    yes brother i am working in TCS and in Java domain and on a project of Telecom Inventory system using java.
    😁ok ok. I am in 4th sem and have just started learning java!😁😁

    Can you help me with this?
    I have downloaded a project on java named "placement office automation"
    The thing is it was a zipped file.When i extracted it i got a folder which contains so many classes and java editor. It contains classes means it is already compiled(this is what i have learned since i compiled my first program😀 ). So i wanted to know how should i analyse this project. i wanted to see how this whole thing works. But since it contains so many classes i dont know should i run each of the class individually or i should do something else!!😕
    any kind of help will be appreciated!!!😀😀

    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberApr 23, 2012

    Can we screenshot of those files here?
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberApr 26, 2012

    manishks
    😁ok ok. I am in 4th sem and have just started learning java!😁😁

    Can you help me with this?
    I have downloaded a project on java named "placement office automation"
    The thing is it was a zipped file.When i extracted it i got a folder which contains so many classes and java editor. It contains classes means it is already compiled(this is what i have learned since i compiled my first program😀 ). So i wanted to know how should i analyse this project. i wanted to see how this whole thing works. But since it contains so many classes i dont know should i run each of the class individually or i should do something else!!😕
    any kind of help will be appreciated!!!😀😀

    look for main class source file and you can see that which class is being imported in program and in this way you can track how the data is flowing through the classes.
    You can simply download eclipse and import the whole project into eclipse. track the main file. and Eclipse automaticaly show you how other files is being used.
    give the link from where you downloaded the project.
    Are you sure? This action cannot be undone.
    Cancel
  • manishks

    MemberApr 27, 2012

    ianoop
    look for main class source file and you can see that which class is being imported in program and in this way you can track how the data is flowing through the classes.
    You can simply download eclipse and import the whole project into eclipse. track the main file. and Eclipse automaticaly show you how other files is being used.
    give the link from where you downloaded the project.
    thank you ianoop 😀 now i understand!! I just searched for java projects on google. I dont exactly remember the site 😛
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberApr 27, 2012

    manishks
    thank you ianoop 😀 now i understand!! I just searched for java projects on google. I dont exactly remember the site 😛
    Then upload your downloaded project to any site like mediafire.com and give the link.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register