Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to compile and run java in UNIX? Post 302740243 by ak3141 on Wednesday 5th of December 2012 11:49:02 PM
Old 12-06-2012
How to compile and run java in UNIX?

Hi

Im using MobaXterm Unix on my windows XP.I want to compile java in unix.I have installed java to the following path C:\Program Files\Java\jdk1.7.0_09\bin

In order to compile the java prog im typing the following command after entering into the bin directory:
Code:
C:\Program Files\Java\jdk1.7.0_09\bin 

$ javac Example.java

But im getting the following message:
Code:
 bash: javac: command not found


plz Help.
Thanks

Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by vbe; 12-06-2012 at 05:37 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

How to compile and run C++ programs in UNIX environment?

:( :confused: Does anybody here know how to compile and run C++ programs in UNIX enviroment? I am so confused. Any help on this would be greatly appreciated! Thanks! (5 Replies)
Discussion started by: Kahuashi
5 Replies

2. UNIX for Dummies Questions & Answers

run a java file on UNIX?

HI, I want to run my .java file on a SunOS 5.8 Unix machine. The java file is writen with Ready to Program (Similar to Jbuilder) on a PC. Thanks!! (3 Replies)
Discussion started by: leotopia
3 Replies

3. Programming

compile java with GUI on unix system/putty

is it possible in the first place? if so, how should I go about it? (0 Replies)
Discussion started by: finalight
0 Replies

4. UNIX for Dummies Questions & Answers

compile .exe, run in unix.

Hi all, I am using putty to access my school unix servers. I have recently downloaded a source file of a software in .tar format. I change the code of the program and compile it in VS8 and build an .exe file. 1) I copy the .exe file to my school account but I could not make it work. How... (2 Replies)
Discussion started by: hkullana
2 Replies

5. Solaris

how to compile and run java programs

Hi, I have installed Solaris 10 on a VMware. How to compile a java program as there is no javac in 'bin' directory. Thanks in advance for answers and sorry if the question is soo basic. (3 Replies)
Discussion started by: mayahari
3 Replies

6. UNIX for Dummies Questions & Answers

trying to compile and run java through the terminal

Hey everybody, Ok here is my problem. I have this code that that compiles, but when i go to run it it gives me errors. I stored my simple java class here: /user/workspace/getMailFromSafeDoc/src I store my mail.jar file here: /user/workspace/getMailFromSafeDoc/lib/javaMail/javaMail.jar ... (2 Replies)
Discussion started by: killesk
2 Replies

7. UNIX for Dummies Questions & Answers

Compile & Run Java Code

The java program is a part of speech tagger -> The Stanford NLP (Natural Language Processing) Group The goal is to use this script as part of a webpage to tag parts of speech based on a user-inputted string. I have no idea what to do with the files - I'm a complete *nix noob. I tried running... (4 Replies)
Discussion started by: tguillea
4 Replies

8. Programming

Run Unix commands from Java

Greeings all Im trying to excute a command from Java and direct the output to the main output screen or to another file .... can you please help with this ? can I use filewriter for this ? Here is my code.... import java.io.BufferedReader; import java.io.File; import java.io.FileWriter;... (3 Replies)
Discussion started by: yahyaaa
3 Replies

9. UNIX for Advanced & Expert Users

java compile and run program help

What is the trick to get a java program to run and compile? I can't even get a basic skeleton to run and compile. What packages do I need? I figured the java-gcj and gcc-java packages was enough. Do I need any other packages? I thought I had to do this and it would work but its not. javac... (1 Reply)
Discussion started by: cokedude
1 Replies

10. Programming

Using basic UNIX commands to make/compile JAVA files

Hello! This is my first post, and I just learned what UNIX was this week. For a JAVA programming class I am taking, I must be able to create a directory in UNIX, use the nano command to create a JAVA program, compile it, and then run it on the command prompt using the java command. For some... (5 Replies)
Discussion started by: UNdvoItX
5 Replies
java(5) 							File Formats Manual							   java(5)

NAME
java, javac, jre, jdb, javah, javap, javadoc, appletviewer, rmic, rmiregistry, serialver, native2ascii, jar, javakey - The Java Develop- ment Kit tools SYNOPSIS
java [ options ] classname <args> java_g [ options ] classname <args> DESCRIPTION
This reference page describes the java command only. The Java Development Kit (JDK) is part of the Java Virtual Machine (VM). If the JDK documentation was installed on your Tru64 UNIX system, you can view documentation on all of the JDK tools, and other Java reference mate- rial, at the following location: /usr/share/doclib/java/index.html The java command invokes an interpreter that executes Java bytecodes. It executes Java class files created by a Java compiler, for instance, javac. NOTES
Any arguments that appear after classname on the command line are passed to the main method of the class. The java command expects the binary representation of the class to be in a file called classname.class, which is generated by compiling the corresponding source file with javac. All Java class files end with the filename extension .class which the compiler automatically adds when the class is compiled. classname must contain a main method defined as follows: class Aclass { public static void main(String argv[]){ . . . } } java executes the main method and then exits unless main creates one or more threads. If any threads are created by main then java doesn't exit until the last thread exits. Ordinarily, you compile source files with javac then run the program using java. However, java can be used to compile and run programs when the -cs option is used. As each class file is loaded its modification date is compared to the modification date of the class source file. If the source has been modified more recently, it is recompiled and the new class file is loaded. java repeats this procedure until all the classes are correctly compiled and loaded. The interpreter can determine whether a class is legitimate through the mechanism of verification. Verification ensures prior to their exe- cution that class files do not violate any language constraints. java_g is a non-optimized version of java suitable for use with debuggers like jdb. EXAMPLES
The classname argument is the name of the class to be executed. classname must be fully qualified by including its package in the name, for example: % java java.lang.String When you define your own classes you need to specify their location. Use CLASSPATH to do this. CLASSPATH consists of a colon separated list of directories that specifies the path. For example: .:/home/xyz/classes The system always appends the location of the system classes onto the end of the class path unless you use the -classpath option to specify a path. OPTIONS
Allows the Java debugger, jdb, to attach itself to this java session. When -debug is specified on the command line, java displays a pass- word which must be used when starting the debugging session. When a compiled class is loaded, this option causes the modification time of the class bytecode file to be compared to that of the class source file. If the source has been modified more recently, it is recompiled and the new class file is loaded. Specifies the path java uses to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. Directories are separated by colons. Thus the general format for path is: .:<your_path> For example: .:/home/xyz/classes:/usr/local/java/classes Sets the maximum size of the memory allocation pool (the garbage collected heap) to x. The default is 16 megabytes of memory. x must be greater than or equal to 1000 bytes. By default, x is measured in bytes. You can specify x in either kilobytes or megabytes by appending the letter k for kilobytes or the letter m for megabytes. Sets the startup size of the memory allocation pool (the garbage collected heap) to x. The default is 1 megabyte of memory. x must be > 1000 bytes. By default, x is measured in bytes. You can specify x in either kilobytes or megabytes by appending the letter k for kilobytes or the letter m for megabytes. Turns off asynchronous garbage collection. When activated no garbage collection takes place unless it is explicitly called or the program runs out of memory. Normally garbage collection runs as an asynchronous thread in parallel with other threads. Turns off garbage collection of Java classes. By default, the Java interpreter reclaims space for unused Java classes during garbage collection. Prints the build version information. Prints a usage message. Each Java thread has two stacks: one for Java code and one for C code. The -ss option sets the maximum stack size that can be used by C code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its C stack size. The default units for x are bytes. The value of x must be greater than or equal to 1000 bytes. You can modify the meaning of x by appending either the letter k for kilobytes or the letter m for megabytes. The default stack size is 128 kilobytes (-ss 128k). Each Java thread has two stacks: one for Java code and one for C code. The -oss option sets the maximum stack size that can be used by Java code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its Java stack size. The default units for x are bytes. The value of x must be greater than or equal to 1000 bytes. You can modify the meaning of x by appending either the letter k for kilobytes or the letter m for megabytes. The default stack size is 400 kilobytes (-oss 400k). Prints a trace of the instructions executed (java_g only). Causes java to print a message to stdout each time a class file is loaded. Runs the verifier on all code. Runs the verifier on all code that is loaded into the sys- tem via a classloader. verifyremote is the default for the interpreter. Turns verification off. Causes the garbage collector to print out messages whenever it frees memory. Redefines a property value. propertyName is the name of the property whose value you want to change and newValue is the value to change it to. For example, this command line % java -Dawt.button.color=green ... sets the value of the property awt.button.color to "green". java accepts any number of -D options on the command line. ENVIRONMENT VARIABLES
Used to provide the system a path to user-defined classes. Directories are separated by colons, for example, .:/home/xyz/classes:/usr/local/java/classes SEE ALSO
If the JDK documentation was installed on your Tru64 UNIX system, you can view it at the following location: /usr/share/doclib/java/index.html delim off java(5)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy