So I am trying to start with Java (as in, trying to get the dang thing to accept code). I download all the needed things (the SDK) from Java and such, but when it gets to the point where I have to do "javac" in Command Prompt to compile the notepad file, I just get the message saying that there is no command called "javac".
Anybody wanna share some insight?
To set the environment variable PATH: http://www.java.com/en/download/help/path.xml.
Also I recommend using an IDE such as netbeans or eclipse. They make it much easier when starting off in java, plus when getting into advanced projects with many classes, they help greatly.
You need to set the path to your java compiler for it to be found when you use the command prompt. This page explains how.
I would suggest setting the following environment variable:,
JAVA_HOME to point to the root of your java installation e.g. C:\Program Files\Java
than append the following to your PATH environment variable:
;%JAVA_HOME%\bin
than you will be able to use java and javac from the command line.
Also see this article from Microsoft on setting environment variables if your not familiar with it.
You need to add the Java bin directory (where javac.exe is located, assuming you're on Windows), to your system PATH.
Right click on "My Computer", go to Environment Variables, and add the bin directory where Java is installed to your PATH variable.
You will need to have the java bin directory on your path. So, on windows, if installed at c:\java, and bin is c:\java\bin (normally you have version number, jre vs sdk, etc), you will need to add that to your PATH environment variable. set PATH=c:\java\bin;%PATH% -- you could do this in a setlocal/endlocal block or set it permanatly for your machine.
Also, the JRE may not have javac -- you may need to dowload the SDK.
Starting with java by typing 'javac' at the command line satisfy my mother's definition of the phrase 'starting with' ... as in,
"Don't start with me, buddy."
You are likely to end up with a punch in the nose.
For your own sanity, pick one of Eclipse, or NetBeans, or IntelliJ, or the other popular IDEs, and start from there.
Related
I'm trying to make Java work with some commands in a .bat file without installation. I have the Java folder that is installed in C:\Program Files when you normally install Java and Init.bat which does this:
set JAVA_HOME="C:\Users\mega\Desktop\DISK\Apps\Java"
set PATH=%PATH%;C:\Users\mega\Desktop\DISK\Apps\Java\bin
assoc .jar=jarfile
ftype jarfile="C:\Users\mega\Desktop\DISK\Apps\Java\bin\javaw.exe" "%1"
It should set the 2 environment variables and associating the variables, first of all, they don't set the variables, I do not know why but I am sure that I can fix it after this topic, but even then, I set them manually and when I try to open a .jar file it doesn't work.
So the Java is in 1 folder and it should function like if a Java were to be installed normally, but it doesn't, any help is good since I can't figure it out.
I unsuccessfully attempted to install Groovy 1.8.6 (zip distribution) on a Win XP (sp3) machine yesterday and today (the error messages stated it was unable to find the groovyStarter then I received a lengthy stack trace...). Needless to say, it was a frustrating experience. So, I decided to use the Windows installer for version 1.8.5. Groovysh functions as it should but if I write a small Groovy script and place it in a file:
println "Hello Groovy Programmer!"
...no output is displayed. Using groovy -e "println 'Hello!'" has the exact same behavior.
Any ideas of what might cause this?
Thanks.
~Caitlin
I'm not sure what you mean by "installing" the binary ZIP distribution. You don't really install anything in the usual sense of the term... you just unzip the ZIP file wherever you like. On my Windows XP laptop, I unzipped its contents into C:\groovy-1.8.6\.
I have heard some people complain of problems when they unzip into a path that contains spaces (such as C:\Documents and Settings\YourUsername\Desktop)... so perhaps that could be your issue, if you unzipped to your Desktop or something.
Just unzip the ZIP file somewhere, and add it's /bin directory to your PATH. On a Windows XP machine:
Right-click "My Computer"
Select "Properties"
Go to the "Advanced" tab
Click the "Environment Variables" button
Edit the PATH variable, and add C:\groovy-1.8.6\bin (or whatever)
The Groovy installation instructions also suggest that you add a GROOVY_HOME variable (pointing to C:\groovy-1.8.6), and a JAVA_HOME variable pointing to the root directory of your Java JDK (not the JRE located inside of the JDK). However, to be honest, I only remember to add these two environment variables half the time when putting Groovy on a a new machine, and it's never caused me problems.
With the ZIP file unzipped, and its /bin directory in your PATH, you just open a command-prompt and type:
groovy <script name>
... or, to run the GUI interface:
groovyConsole
If by chance you saw those "groovyStarter" errors because you tried to run startGroovy, then use one of the two commands above instead. The "startGroovy.bat" command is an internal script intended for indirect use through the other scripts under /bin. It will throw a java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter stacktrace if you call it directly... because it needs one of the other scripts to set some variable prior to calling it.
Good luck!
What are the path variable supposed to be to ensure "javac" will work? Should it be in both system and user variables and should the "\bin" part be included?
I have a Program Files and Program Files(x86) and the JDK is in both. Which one should i use? Eclipse is working perfectly, it's only when using command line that I get this. Anyone?
Eclipse comes with its own Java compiler, it doesn't have to use an external one.
You should find the bin directory under whichever JDK you want to use and then add it to the path (I prefer the user path but, since I only ever run as one user, I'm not sure what the difference is).
And make sure it's the JDK, not just the JRE.
For example, mine is in c:\program files\java\jdk1.6.0_17\bin (32-bit WinXP).
One final thing, if you're changing the environment variables in the control panel, that won't affect cmd windows that are already open. You'll need to open up a new one to get the new environment settings (trap for wary players).
I built an application in Netbeans 6.8 and made project.jar file. When I run it, it works only on my computer, but not on any other computer. However, when I made any simple application, that doesnt use any libraries, it works fine on any computer.
Is there any way, how to invoke some error message, where is the problem?
My project use R 2.9.2, so I install this version on other computer and set the System Path variable exactly same. Other libraries listed in lib directory are: AbsoluteLayout.jar,DatePicker-V0.99-2006.09.01.jar,jcommon-1.0.16.jar,jfreechart-1.0.13.jar,jmathplot.jar,JRI.jar,pdf-renderer-1.0.5.jar
Thank you
You don't get any message at all? What do "works" and "not works" look like?
You sound like another person who hasn't taken the time to learn how to do things by hand on the command line without an IDE. I'd recommend doing that. Open a command shell and type in the java -jar -cp ... foo.jar command to run your stuff. The messages you get back will be educational.
Note the -cp command line argument. That's how you add your JARs to the CLASSPATH properly.
I solved this problem as follows, maybe it will help someone.I add 2 paths in PATH system variable:
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH.
you must add both paths, to jri.dll and r.dll, in my case it were these:
C:/Program Files/R/R-2.9.2/bin/;C:/Program Files/R/R-2.9.2/library/rJava/jri/;
I have added these lines already, but with different different slash. So be careful, you must use it / not \ to define path!!!
I can run my project through netbeans but after I make a jar file and double click it I get the error cannot find Java runtime environment? I am on Windows.
You don't have a file associate created. Right click on the .jar file in Internet Explorer, select Open With, and navigate to your JRE. Select the java.exe executable, and make sure the command-line argument has ' -jar ' present.
The .jar file will be passed as the first argument to the JVM.
Make sure you have JRE installed.
Open the console and type java -version
You should download a Java runtime environment.
You might try, as Chris said, making sure the JRE executable is part of your PATH environment variable. Check out "4. Update the PATH variable (Optional)" from this guide.
Make sure the JRE bin dir is in your PATH env variable.
It's all about the Manifest - http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html
In Netbeans run the project. It will ask you what class to run (you will see a list of all the classes with a "public static void main(String[])" method). Once you do that the next time you build the class netbeans will show you how to run it (with the -jar witch). Now you should be able to double click on it.