• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Issues Compiling With Javac

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, so my current problem is that I can't seem to get Javac to compile class files properly. Now then, my problem comes from the fact that when attempting to compile a .java file in cmd prompt, using javac.exe, I don't get any error messages what so ever, everything seems to run perfectly fine, however.... After the process finishes, I can't find the .class file that was supposed to have been compiled anywhere. See the thing is, javac isn't showing me any errors, and it also isn't creating my .class file anywhere, even after searching my entire computer I can't find the file anywhere. To the best of my knowledge I'm not doing anything wrong.

To add on to all of this, I don't seem to have the path set up wrong for cmd prompt. Based on everything I've read, my path file seems to be set up in the proper manner, this is what I've added onto the previously existing path : ";C:\Program Files\Java\jdk1.6.0_11\bin". If anyone has any idea what my problem is, I would greatly appreciate the help, because as it stands, I can't seem to find a solution to my problem anywhere.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us what you type at the prompt ?
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you also show us the first few lines of the class? ... particularly the "package" line, and the name of the class.

Henry
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, well as to what I'm typing into command prompt, the line is simply this "javac HelloWorld.java". I already set up the directory path in prompt using the line "CD \Program Files\JavaProjects", the .java file is located in this directory. As for package line, the first line is just "import java.io.*;" , and just to add to that, obviously I'm just running a simple "HelloWorld" program at the moment which I know has no errors into it just to see whether or not I'll be able to manage to compile the file into a .class file. If the phrasing of my original question was ambiguous, or the terminology I used was wrong, I'm sorry, but I'm also rather new to Java so it's a tad difficult to fully describe the problem.
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, simce it is a small Hello World program, can you just copy and paste it here?

Henry
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure thing, here's the entire code :
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting... and when you type ....


C:\Program Files\JavaProjects> javac HelloWorld.java

C:\Program Files\JavaProjects>


You said nothing happens? No errors. The prompt just comes back? And there isn't a class file?

Henry
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is exactly what my problem is. No errors are reported and no .class file is created.
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a Java issue. You have something wrong with the setup...

To add on to all of this, I don't seem to have the path set up wrong for cmd prompt. Based on everything I've read, my path file seems to be set up in the proper manner, this is what I've added onto the previously existing path : ";C:\Program Files\Java\jdk1.6.0_11\bin".




Remove it from the path -- and try it again... I am thinking you have something else that is running.

Henry
 
Henry Wong
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, you can also show us your path... by typing this...

C:\Program Files\JavaProjects> echo %PATH%


You can try to check the version with...

C:\Program Files\JavaProjects> javac -version


But if it is not printing anything, then the version may be gone too.

Henry
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, well I tried removing it from the path, no luck. In fact at this point I can't even get the version to print in command prompt anymore (which I was able to do before). So I guess this is an issue with the path, but right now I'm still using the same path that I was using before, except now nothing is working at all.
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind, at this point I can use the -version command again, but the file still wont compile into a class file when using the line "javac HelloWorld.java". To add onto this, when I use the version command it returns "javac 1.6.0_11".
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, how do you check if there is a .class file or not ? Do you check it at the prompt ?
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried searching for the .class file using various methods, from trying the "dir" command, to physically opening the folder where I expect it to be, and then finaly just doing a full out search of my computer to see if it ended up somewhere I didn't expect it. I have yet to be able to find the file through any of these methods.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you try "javac -verbose HelloWorld.java" ?
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, so I ran "javac -verbose HelloWorld.java". I got a huge amount of text, and at the end is said "[wrote HelloWorld.class]", however, it still doesn't seem to be anywhere on my computer... so, yeah, I have no idea what's going on, it seems to be creating the class, but not saving it anywhere?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you working locally or are you working on some kind of network drive ?
 
Joe Malone
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm doing all of this work locally, everything is based on this one computer that I'm using to try to compile everything. When I have a chance tommorow (assuming the problem isn't fixed by then) I'll try to run the same code on a different computer and see if javac has any better luck giving me a class file there.
 
Ranch Hand
Posts: 106
Mac Mac OS X Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you working on windows? if yes, is always a good practice to do the following:

create a new folder inside the director where your HelloWorld.java is (C:\Program Files\JavaProjects).
On your new folder, try compiling the .java again.

C:\Program Files\JavaProjects\YourNewFolder>javac HelloWorld.java

and then check if your class is on this directory(YourNewFolder).


i'm not sure if it'll work, but it's a good thing to do considering you are working on windows.
also, it'll make us to have sure of what kind is the problem, instead of discussing for something that could be very simple...

what the cost of making a simple test only for having sure?

 
Marshal
Posts: 79698
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lucas Franceschi wrote:are you working on windows? if yes, is always a good practice to do the following:

create a new folder inside the director where your HelloWorld.java is (C:\Program Files\JavaProjects).

Good idea to create a new folder, whichever operating system you are on, but do you really mean to create it inside Program Files?

I would suggest:
  • open a command line
  • create a directory with the instruction "mkdir Java" or similar
  • Navigate to that folder with the instruction "cd Java"
  • Save your .java files in that folder.
  • You can create other nested directories as required.
  • For your simple classes, compile them with the javac command in that folder.
  • You will have a Java folder inside "my documents" if you don't navigate anywhere before writing "mkdir".

    By the way: When the javac tool has successfully compiled a .java file, you don't see any messages at all. You simply get the prompt again.
     
    Lucas Franceschi
    Ranch Hand
    Posts: 106
    Mac Mac OS X Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:...but do you really mean to create it inside Program Files?



    I dont see how could it change something in this case, but you can create your new folder where you want, being only a simple hello world program, you only would need to make sure your classpath is set properly (in this case, it is.) so only the java file itself can work, put this java file in a new folder, no matter where this folder is =D
     
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi, I'm having a different compile problem with javac. I just downloaded J EE 5 SDK from Sun and added it to the CLASSPATH variable, but my servlet will not compile due to package javax.servlet.http does not exist. My classpath is as follows:

    C:\Sun\SDK\jdk\jre\lib\rt.jar; c:\Sun\SDK\lib\j2ee.jar; c:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;c:\StudentWork\jr.jar

    Does anyone have any suggestions?

    Thanks.
     
    Henry Wong
    author
    Posts: 23956
    142
    jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Does anyone have any suggestions?



    Please don't hijack this topic. The poster of this topic has yet to resolve the issue. And probably doesn't appreciate changing the subject.

    Please start a new topic for a new issue.

    Henry
     
    Joe Malone
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for all the help, it seems the mistake was just the fact that I was trying to save it in program files. As soon as I moved the folder into my documents instead, it began to work. Thanks for all the help, and I'm glad this problem has finaly been resolved.
     
    Lucas Franceschi
    Ranch Hand
    Posts: 106
    Mac Mac OS X Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    good work.
     
    Jim Buechler
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sorry about that. I am new to this, so I didn't know. I'll start a new topic.

    Thanks.
     
    My cellmate was this tiny ad:
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic