Java Help! Unable To Run Java Programs.

manishks
@manishks-AZybhs โ€ข Oct 27, 2024

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

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • younus786

    @younus786-bQiN7D • Apr 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.....

  • manishks

    @manishks-AZybhs • Apr 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.๐Ÿ˜”๐Ÿ˜”

  • manishks

    @manishks-AZybhs • Apr 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???

  • Anoop Kumar

    @anoop-kumar-GDGRCn • Apr 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-#

  • Anoop Kumar

    @anoop-kumar-GDGRCn • Apr 20, 2012

    musicfreakmandyPath>.... 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-AZybhs • Apr 20, 2012

    thanx ianoop ๐Ÿ˜€
    can i use netbeans instead of eclipse??????

  • Anoop Kumar

    @anoop-kumar-GDGRCn • Apr 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.

  • manishks

    @manishks-AZybhs • Apr 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!!!

  • manishks

    @manishks-AZybhs • Apr 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!!!!!!๐Ÿ˜๐Ÿ˜

  • yanivx

    @yanivx-gvxfxa • Apr 22, 2012

    musicfreakmandyI 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-AZybhs • Apr 22, 2012

    yanivxMaking 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-bQiN7D • Apr 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

  • manishks

    @manishks-AZybhs • Apr 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! ๐Ÿ˜€

  • Sahithi Pallavi

    @sahithi-oJZaYj • Apr 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-#

  • manishks

    @manishks-AZybhs • Apr 22, 2012

    Thanks for the link sada. ๐Ÿ˜€ it will be really helpful. ๐Ÿ˜€

  • yanivx

    @yanivx-gvxfxa • Apr 23, 2012

    musicfreakmandyYa 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-AZybhs • Apr 23, 2012

    yanivxyes 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-oJZaYj • Apr 23, 2012

    Can we screenshot of those files here?

  • Anoop Kumar

    @anoop-kumar-GDGRCn • Apr 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.

  • manishks

    @manishks-AZybhs • Apr 27, 2012

    ianooplook 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-GDGRCn • Apr 27, 2012

    manishksthank 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.