Java Help! Unable To Run Java Programs.

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😭😭 !!!πŸ˜€


Replies

  • younus786
    younus786
    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
    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 Specify where to find user class files
    -cp Specify where to find user class files
    -sourcepath Specify where to find input source files
    -bootclasspath Override location of bootstrap class files
    -extdirs Override location of installed extensions
    -endorseddirs Override location of endorsed standards path
    -d Specify where to place generated class files
    -encoding Specify character encoding used by source files
    -source Provide source compatibility with specified release

    -target 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 Pass 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.....
  • manishks
    manishks
    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.πŸ˜”πŸ˜”
  • manishks
    manishks
    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???
  • Anoop Kumar
    Anoop Kumar
    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 .java.
    after copiling you will see class file in same directory will be created.
    run by:
    java 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-#
  • Anoop Kumar
    Anoop Kumar
    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.
  • manishks
    manishks
    thanx ianoop πŸ˜€
    can i use netbeans instead of eclipse??????
  • Anoop Kumar
    Anoop Kumar
    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.
  • manishks
    manishks
    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!!!
  • manishks
    manishks
    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!!!!!!😁😁

  • yanivx
    yanivx
    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 πŸ˜€
  • manishks
    manishks
    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? ?
  • younus786
    younus786
    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
  • manishks
    manishks
    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! πŸ˜€
  • Sahithi Pallavi
    Sahithi Pallavi
    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-#
  • manishks
    manishks
    Thanks for the link sada. πŸ˜€ it will be really helpful. πŸ˜€
  • yanivx
    yanivx
    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.
  • manishks
    manishks
    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!!!πŸ˜€πŸ˜€

  • Sahithi Pallavi
    Sahithi Pallavi
    Can we screenshot of those files here?
  • Anoop Kumar
    Anoop Kumar
    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.
  • manishks
    manishks
    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 πŸ˜›
  • Anoop Kumar
    Anoop Kumar
    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.

You are reading an archived discussion.

Related Posts

Hi all of you, myself Shuvam from M.S. Ramaiah college Bangalore. First of all i must say Crazy Engineer is an awesome blog for freshers like us. Well coming to...
hey guys aNaN from india ...πŸ˜€ a mechanical engineer 😁
guys i need some help with regard to my project i want to heat an aluminum alloy pin (A-356) to a temperature upto 300 degree celcius is this possible through...
Hello friends, I have an 10 year experience in electronic hardware industry and want to do something growth of income. Can anyone suggest/introduce me some products based on PCB Assembly...
Can I change my username on crazyengineer? if yes how?