• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

running javac from any folder

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys, I am tying to set up the java compiler on a new computer, I downloaded the jdk and the compiler works, but it only works when I'm in C:\Program Files\Java\jdk1.5.0\bin. Is there a way to make it so that both the compiler and the jvm work in any folder on the computer? or at least a different specifed folder?
-Thanks Dan
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add {JAVA_HOME}/bin to your PATH
where {JAVA_HOME} is the home directory of your java installation (like C:\j2sdk.1.4 ...)
 
Dan Maples
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you explain to me how to do that please?
Thanks- Dan
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How the PATH is set depends on your operating system. So, what are you running?

Note that the steps to set most any operating system environment variable for a particular operating system are about the same. So, you be able to figure it out by taking a look at HowToSetTheClasspath for the steps to take.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marilyn,

I have done this,I have set the path as
C:\j2sdk1.4.2_04\bin;c:\j2sdk1.4.2_04\bin\javaexamples1
When I try to run the files of javaexamples1 from c:> error cannot read.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly are you doing to get exactly what error message?

Please post your question in a new thread if the topic is different.
 
kiran vydhyam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excuse me for the confusion,I was referring to the same above thread topic.
I'am trying to run the java source files from c:> ,for this I have set the path to
c:>j2sdk1.4.2_04\bin\javaexamples
I have my source files in javaexamples folder.
Even though the files don't get executed.It gives an error message as
Error: Cannot read A.java
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should only add the path to the executable files (javac.exe, java.exe and so on) found in c:>j2sdk1.4.2_04\bin to the PATH. This is to help your OS find the commands you want to use. When this is done you should be able to compile and run your java-files in any folder on your computer.
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are having trouble compiling (javac ...), you need to set your PATH.
If you are having trouble running the compiled classes, you need to set your CLASSPATH. I can't see from your question which you are having problems with.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, what exactly are you doing to get exactly what error message?

It might help if you were to clarify, exactly what command are you executing.

Also, note that you can't run a source file. You first need to compile them, and then run a class.
[ July 26, 2004: Message edited by: Dirk Schreckmann ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kiran vydhyam
Error: Cannot read A.java, right?
I used to have a similar problem. I think the editor you are working on is adding it's own extension to your java file. For example when you save you have something like: A.java.txt right?
This time, when you save, include " ". For example, "A.java"
That should allow javac to read A
Maybe to hide extensions for known file types may be permanent.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic