Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34

Thread: running java files in the cmd.exe

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: running java files in the cmd.exe

    Where is the MyClass.java file? I do not see it listed in the HP folder. It needs to be in the folder where the javac.exe program is being executed.
    This line from your console:
    C:\Users\HP>javac MyClass.java
    shows that the javac command was executed in the HP folder. That is where the MyClass.java file needs to be located.


    Back in post#21 the javac command found the MyClass.java file in the HP folder. Where did it go?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Junior Member
    Join Date
    Dec 2019
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: running java files in the cmd.exe

    Quote Originally Posted by Norm View Post
    Where is the MyClass.java file? I do not see it listed in the HP folder. It needs to be in the folder where the javac.exe program is being executed.
    This line from your console:
    shows that the javac command was executed in the HP folder. That is where the MyClass.java file needs to be located.


    Back in post#21 the javac command found the MyClass.java file in the HP folder. Where did it go?
    i put it in a folder, myJava, but i removed it now n pasted it on the HP.ran the command, ds what i got:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\HP>javac MyClass.java
    MyClass.java:1: error: illegal character: '\u00bb'
    public class MyClass {
    ^
    MyClass.java:1: error: illegal character: '\u00bf'
    public class MyClass {
    ^
    2 errors

    C:\Users\HP>

    ds is d dir run ds tym:
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.

    C:\Users\HP>dir
    Volume in drive C has no label.
    Volume Serial Number is 76EB-4A60

    Directory of C:\Users\HP

    12/26/2019 10:53 PM <DIR> .
    12/26/2019 10:53 PM <DIR> ..
    12/12/2019 11:02 PM 0 'javac'
    12/25/2019 05:15 PM 95 .accessibility.properties
    11/18/2019 06:08 PM <DIR> .AndroidStudio3.5
    12/26/2019 07:51 PM <DIR> .eclipse
    11/18/2019 08:56 PM <DIR> .gradle
    12/26/2019 07:51 PM <DIR> .jmc
    11/19/2019 09:41 PM <DIR> AndroidStudioProjects
    10/24/2016 02:07 PM <DIR> biocapture-sync
    12/17/2019 12:16 AM <DIR> Contacts
    12/18/2019 11:13 PM <DIR> Desktop
    12/23/2019 10:31 PM <DIR> Documents
    12/24/2019 05:55 PM <DIR> Downloads
    11/29/2019 03:04 PM <DIR> Favorites
    12/22/2019 05:04 PM <DIR> java jdk
    12/05/2019 11:28 AM <DIR> java runtimE
    12/12/2019 11:02 PM 0 javac
    05/19/2019 05:45 PM 0 lib.defs
    11/21/2015 01:28 AM <DIR> Links
    12/03/2019 10:46 PM <DIR> Music
    12/24/2019 11:48 PM 119 MyClass.java
    12/26/2019 10:53 PM <DIR> myJava
    12/12/2019 11:02 PM 0 operable
    11/12/2019 11:37 PM <DIR> Pictures
    11/21/2015 01:28 AM <DIR> Saved Games
    12/16/2019 11:47 PM <DIR> SCHU tools
    03/10/2019 10:48 PM <DIR> Searches
    12/15/2019 07:23 AM <DIR> spss
    11/12/2019 11:37 PM <DIR> Videos
    6 File(s) 214 bytes
    24 Dir(s) 245,995,196,416 bytes free

    C:\Users\HP>

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: running java files in the cmd.exe

    C:\Users\HP>javac MyClass.java
    MyClass.java:1: error: illegal character: '\u00bb'
    public class MyClass {
    ^
    That shows the MyClass.java file was found by the javac command. Now you need to change the source file to a proper text file.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #29
    Junior Member
    Join Date
    Dec 2019
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: running java files in the cmd.exe

    Quote Originally Posted by Norm;
    "That shows the MyClass.java file was found by the javac command. Now you need to change the source file to a proper text file."
    how do i do it. i have been changing directories. have changed from unicode-utf-8-ANSI, changed saving from all files to text type, then back to all files...how will I CHANGE tHE SOURCE FILE TO a PROPER text fiLE?
    Last edited by Chinedu & ICT; December 26th, 2019 at 06:28 PM.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: running java files in the cmd.exe

    i have been changing directories.
    It has nothing to do with the directory. Edit the file and save it as ANSI
    If you don't understand my answer, don't ignore it, ask a question.

  6. #31
    Junior Member
    Join Date
    Dec 2019
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: running java files in the cmd.exe

    It has nothing to do with the directory. Edit the file and save it as ANSI
    I'm happy this morning. i successfully compiled, ran and executed my first java programming this morning. i was on it yesternight, watched an online video and saved the file as ANSI, tried compiling the MyClass.java but it wasn't successful. i left it and turned in for the night. read ur msg this morning wn i woke up and decided to try javac MyClass.java again. it paid off. thanks a million @norm, u hv bn a brother. this is the breakfast cmd.exe gave me:

    C:\Users\HP>cd Documents

    C:\Users\HP\Documents>javac MyClass.java

    C:\Users\HP\Documents>java MyClass
    chinedu and ict

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: running java files in the cmd.exe

    I am glad you now have it working.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #33
    Junior Member
    Join Date
    Dec 2019
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: running java files in the cmd.exe

    Quote Originally Posted by Norm View Post
    i'm glad ...
    thank u. i observed that javac fails when i'm in HP(thats my computer), but compiles MyClass.java when i cd to Documents.
    Last edited by Chinedu & ICT; December 27th, 2019 at 04:30 PM.

  9. #34

    Default Re: running java files in the cmd.exe

    Hey just take a look on https://learnprogramo.com/how-to-run...using-notepad/ Hope you have cleared your doubt[COLOR="Silver"]

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Cannot read files while running program from JAR-file
    By iHank in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 27th, 2014, 01:26 PM
  2. Replies: 1
    Last Post: November 28th, 2013, 01:14 AM
  3. Replies: 21
    Last Post: June 12th, 2013, 11:33 AM
  4. Running a java applet inside a java window?
    By frozen java in forum Java Theory & Questions
    Replies: 3
    Last Post: July 3rd, 2012, 10:55 PM
  5. JDIC init Exception while running Flash files (.swf) through Java Swings
    By kushima@gmail.com in forum AWT / Java Swing
    Replies: 1
    Last Post: March 1st, 2012, 05:40 AM