Classpath and java.exe, help me, guys

if i don't use -classpath for java.exe, what else i can do which affects -classpath or class enviromnent?
thx

You can set the classpath in your system environment or in your IDE (if you use one)

Similar Messages

  • Javac.exe  is not using classpath, while java.exe is.

    I'll state the problem, then give my configuration. This does NOT seem to be a duplicate of other problems. I am running Windows NT sp 6a.
    INTRO:
    javac.exe, java.exe in directory E:\v\bin.
    file HelloWorld.java is in directory E:\v\lib\x\y (dir names shortened)
    PROBLEM:
    Once HelloWorld is compiled (and HelloWorld.class is in E:\v\lib\x\y ), I can run the exact command "java HelloWorld" from ANY directory anywhere and it runs and prints Hello World!.(So java.exe seems to be using classpath.)
    However, to compile, the command "javac HelloWorld.java" does not work (say in E:\v). The error message is "cannot read: "HelloWorld.java". I have to provide the full path name for HelloWorld.java, thus: "javac E:\v\lib\x\y\HelloWorld.java". This works, from any directory anywhere. In other words, javac.exe does NOT seem to be using classpath.
    CONFIGURATION:
    CLASSPATH is set to E:\v\lib\x\y in both system and user environment and ALSO through both javac -classpath and java -classpath. (When I run javac -classpath E:\v\lib\x\y, the list of options is not printed out, and I think this means the classpath is supposed to be set. ) I also tried setting sourcepath for javac, but that did not help.
    PATH is set since and the system recognizes the commands "java" and "javac" from any directory anywhere (each brings up the list of options.)
    Any thoughts.

    let's read the documentation first shall we ...
    http://java.sun.com/j2se/1.4.1/docs/tooldocs/windows/javac.html
    According to it the command line arguments must be file names. The compiler "cannot read HelloWorld.java" because it simply is not in the current working directory. You need to specify a path to the file. It is only after that, "when compiling a source file", that the classpath or sourcepath setting has any effect.

  • Oracle.exe and java.exe are running my CPU 100% under XP Prof SP3

    11gR1
    oracle.exe and java.exe are running 100% CPU
    I have increased virtual memory to 4 gig
    I have defragmented the drive.
    I checked the drive for errors.
    I am searching the whole drive for viruses
    I do not have the problem with Redhat Fedora 12 running 11gR1
    I have 1 gig of RAM but cannot install release 2 because the installer expects
    1 gig + 1

    ooops!!! left that off...sorry
    XP Prof SP3 32 bit..*.no problem with Redhat Fedora 12 running MySQL and 11gR1*
    1 gig RAM Dell precision W/S 1.5 Gig rate 74 GiG SCSI HD 15000 RPM
    Don't pass out but I am also running MySQL server 5.1.41 and MS SQL Server Express 2008.
    Lucky it didn't catch fire
    I installed XP prof months ago but this CPU domination occurred only starting last night!
    However slow everything works in 11gR1
    sqlplus myname/password and then select rows from table
    sqldeveloper
    PHP web sites
    I've had plenty of trouble with Java running slow and hogging memory!
    Edited by: landonmkelsey on May 2, 2010 12:21 PM
    Edited by: landonmkelsey on May 2, 2010 12:24 PM
    Let me guess...stop services for MySQL and MS SQL Server and see what happens!
    Edited by: landonmkelsey on May 2, 2010 12:26 PM

  • Windows xp and java.exe problem

    Hello all..
    I tried to execute have a batch file consisting a jar file and classes in windows xp platform. I used j2sdk1.4.0_03. All my classes are stored in : C:\MyDocument\Softwares\classes directory
    and the jar files are in: C:\MyDocument\Softwares.
    I wrote the following commands in the batch file:
    java -classpath C:\MyDocument\Softwares\classes;
    C:\MyDocument\Softwares\jexcelapi.jar mainClass
    When I lauched that batch file, a message came out:
    java.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
    Could you tell me where the problem is and why? Do I need windows xp patch to eliminate the problem? And where can I find that patch?
    Thanx for any suggestions...
    Richard

    Thanks for your comments. I have tried to reinstall the J2SDK, but then another error message appeared:
    Error occured during the initialization of VM
    java/lang/NoClassDefFoundError:java/lang/Object
    I've checked my Path and it's set as following:
    C:\j2sdk1.4.0_03\bin;
    and my classpath setting:
    C:\MyDocument\Softwares;C:\MyDocument\Softwares\classes;C:\j2sdk1.4.0_03\lib;
    When I tried to execute the java command in any directory (inclusively in C:\MyDocument\Softwares) I always got that message. The only directory where I was able to run the command is in C:\j2sdk1.4.0_03\bin;
    Before I did the reinstallation, I never had such a problem.
    Have any hits? Thanks in advance..

  • Need help with batch file for javac.exe and java.exe

    I have this in my batch file:
    c:\jdk1.3.1_05\bin\javac
    What symbol do I need to be able to run this from cprompt with any file following it

    Thanks could remember that for nothing

  • MS Access and Java JDBC help!

    Hello, I having trouble with a java GUI.
    I have a MS Access named Database.mdb with a table named Customer which I want my GUI to access.
    I want my GUI to be able to flick through the records using the field I have made for them.
    I already have connected the database using windows xp's "System DSN" and have no problem creating tables using sql statements in my code
    Who can help me? any information would be great.
    Thanks

    I'm doing an inventory software application too...but my application is an automatic software inventory, is automatic your application??
    My result is the software that are intalled in a machine..is your project too?
    Sorry, my english is not very good...

  • Java.io and java.swing help

    i'm writing a program that write the byte representation of numbers and outputs them to a joptionpane window
    it keeps telling me that void functions are not allowed
    is there any way that i can use void functions in my output? or would i need to change to a method that returns a value?
    here is my code, please help me, it will be greatly appreciated :)
    GUI Part
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class zero2nineTest extends JFrame{
         zero2nine show;
         public static void main(String[] args){
              zero2nineTest x = new zero2nineTest();
              x.setVisible(true);
         public zero2nineTest(){
              super("File IO and Byte Representation Tests");
              Container cp = getContentPane();
              cp.setLayout(new FlowLayout());
              JButton readFile1 = new JButton("Create and Read 1st Byte Representations");
              readFile1.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        zero2nine.writeFile(out);
                        JOptionPane.showMessageDialog(
                             zero2nineTest.this,
                             "Odd numbers: " + zero2nine.readFile(), "Byte Representation of Odd Numbers",
                             JOptionPane.PLAIN_MESSAGE);
                   cp.add(readFile1);
              JButton readFile2 = new JButton("Create and Read 2nd Byte Representations");
              readFile1.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        zero2nine.writeFile2(out);
                        JOptionPane.showMessageDialog(
                             zero2nineTest.this,
                             "Even numbers: " + zero2nine.readFile2(), "Byte Representation of Even Numbers",
                             JOptionPane.PLAIN_MESSAGE);
                   cp.add(readFile2);
              JButton quit = new JButton("Quit Program");
              quit.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        int decision;
                        decision = JOptionPane.showConfirmDialog(
                             null, "Are you sure?", "Are you sure?", JOptionPane.YES_NO_OPTION);
                             if(decision == 0){
                                  System.exit(0);
                   cp.add(quit);
                   pack();
    Class Part
    import java.io.*;
    class zero2nine{
         static String fileName = "zero2nine.txt";
    //     public static void main(String[] args){
    //          try{
    //               FileOutputStream out = createFile();
    //               writeFile(out);
    //               writeFile2(out);
    //               readFile();
    //               readFile2();
    //          }catch(IOException io){
    //               System.out.println("closing program");
         static FileOutputStream createFile() throws IOException{
              File f = new File(fileName);
              FileOutputStream out = new FileOutputStream(f);
              return out;
         static void writeFile(FileOutputStream out) throws IOException{
              DataOutputStream ds = null;
              try{
                   ds = new DataOutputStream(out);
                   int x = 0;
                   for(int i = 0; i < 10; i++){
                        x = i * i;
                        ds.writeInt(x);
              }finally{
                   System.out.println("File written this far");
         static void writeFile2(FileOutputStream out) throws IOException{
              DataOutputStream ds = null;
              try{
                   ds = new DataOutputStream(out);
                   int x = 0;
                   for(int i = 10; i < 20; i++){
                        x = i * i;
                        ds.writeInt(x);
              }finally{
                   System.out.println("File written this far again");
         public int readFile() throws IOException{
              DataInputStream dataIn = null;
              try{
                   FileInputStream in = new FileInputStream("zero2nine.txt");
                   dataIn = new DataInputStream(in);
                   //Output odd numbers
                   for(int i = 0; i < 10; i++){
                        if(dataIn.readInt() % 2 == 0){
                             int b = dataIn.readInt();
                             System.out.println(b);
              }finally{
                   System.out.println("File read this far");
                   return(b);
         static void readFile2() throws IOException{
              DataInputStream dataIn = null;
              try{
                   FileInputStream in = new FileInputStream("zero2nine.txt");
                   dataIn = new DataInputStream(in);
                   //Output even numbers
                   for(int i = 10; i < 20; i++){
                        if(dataIn.readInt() % 2 == 1){
                             int b = dataIn.readInt();
                             System.out.println(b);
              }finally{
                   System.out.println("File read this far again");
    }

    F:\Computer Science\Java\zero2nineTest.java:28: cannot resolve symbol
    symbol: variable out
                        zero2nine.writeFile(out);
    ^
                   public void actionPerformed(ActionEvent e){
                        zero2nine.writeFile(out);
                        JOptionPane.showMessageDialog(
    F:\Computer Science\Java\zero2nineTest.java:31: 'void' type not allowed here
                             "Odd numbers: " + zero2nine.readFile(), "Byte Representation of Odd Numbers",
    ^
                             zero2nineTest.this,
                             "Odd numbers: " + zero2nine.readFile(), "Byte Representation of Odd Numbers",
                             JOptionPane.PLAIN_MESSAGE);
    F:\Computer Science\Java\zero2nineTest.java:41: cannot resolve symbol
    symbol: variable out
                        zero2nine.writeFile2(out);
    ^
                        zero2nine.writeFile2(out);
                        JOptionPane.showMessageDialog(
                             zero2nineTest.this,
    F:\Computer Science\Java\zero2nineTest.java:44: 'void' type not allowed here
                             "Even numbers: " + zero2nine.readFile2(), "Byte Representation of Even Numbers",
    ^
                             zero2nineTest.this,
                             "Even numbers: " + zero2nine.readFile2(), "Byte Representation of Even Numbers",
                             JOptionPane.PLAIN_MESSAGE);
    4 errors
    Tool completed with exit code 1

  • What does java.exe do if double pass same classpath to it?

    By default, java.exe loads rt.jar as default classpath.
    if user explicitly passes rt.jar as classpath in command line to java.exe again, does java.exe load rt.jar twice or only once?
    Loading same classpath twice is slower than only once - i need the answer for speeding my application.

    By default, java.exe loads rt.jar as default
    classpath.Not correct. rt.jar is not loaded "as default classpath." It should not be listed on the classpath, as it WILL BE searched, and WILL slow down the tools.
    The classpath is used by javac.exe and java.exe (and other tools) to locate your (the user) .java and .class files that they require.
    Read these topics to learn how the classpath works and how to use it correctly:
    Setting the Classpath and
    How Classes are Found
    from this page http://java.sun.com/j2se/1.4.2/docs/tooldocs/tools.html

  • A simple Java program to be compiled with ojc and executed with java.exe

    Hi ,
    This thread is relevant to Oracle Java Compiler (file ojc) and jave.exe file.
    I have written a simple java program which consists of two simple simple classes and using the JDev's 10.1.3.2 ojc and java files , i'm trying to execute it after the successful compilation....
    The problem is that trying to run it... the error :
    Exception in thread "main" java.lang.NoClassDefFoundError: EmployeeTest
    appears.
    How can i solve this problem...????
    The program is as follows:
    import java.util.*;
    import corejava.*;
    public class EmployeeTest
    {  public static void main(String[] args)
       {  Employee[] staff = new Employee[3];
          staff[0] = new Employee("Harry Hacker", 35000,
             new Day(1989,10,1));
          staff[1] = new Employee("Carl Cracker", 75000,
             new Day(1987,12,15));
          staff[2] = new Employee("Tony Tester", 38000,
             new Day(1990,3,15));
          int i;
          for (i = 0; i < 3; i++) staff.raiseSalary(5);
    for (i = 0; i < 3; i++) staff[i].print();
    class Employee
    {  public Employee(String n, double s, Day d)
    {  name = n;
    salary = s;
    hireDay = d;
    public void print()
    {  System.out.println(name + "...." + salary + "...."
    + hireYear());
    public void raiseSalary(double byPercent)
    {  salary *= 1 + byPercent / 100;
    public int hireYear()
    {  return hireDay.getYear();
    private String name;
    private double salary;
    private Day hireDay;
    For compilation... i use :
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdev\bin\ojc -classpath D:\E-Book\Java\Sun_Java_Book_I\Corejava EmployeeTest.java
    For execution , i issue the command:
    D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    NOTE:I tried to use the jdk of Oracle database v.2 but the error :
    Unable to initialize JVM appeared....
    Thanks , a lot
    Simon

    Hi,
    Thanks god....
    I found a solution without using Jdev.....
    C:\oracle_files\Java\Examples>SET CLASSPATH=.;D:\E-Book\Java\Sun_Java_Book_I\Corejava
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\javac EmployeeTest.java
    C:\oracle_files\Java\Examples>D:\ORACLE_UNZIPPED\JDeveloper_10.1.3.2\jdk\bin\java EmployeeTest
    What does Ant has to do with this?Sorry, under the Ant tree a classpath label is found....I'm very new to Java and JDev...
    You need to include the jar file that has the Day method in it inside project properties->libraries.I have not .jar file.. just some .java files under the corejava directory.... By the way , I have inserted the corejava directory to the project pressing the button Add Jar/Directory.... , but the problem insists..
    Thanks , a lot
    Simon

  • Java.exe in c:\winnt\system32?

    Hi,
    I have installed J2SE1.3.1 and J2EE 1.3 b2 on my win2000pro machine and was experimenting with my environment.
    In J2SE1.3.1 installation instructions it was said, that for convenience you can set path to
    point to your j2se1.3.1\bin dir... Ok. Did that. I had a path like follows:
    path=c:\winnt;c:\winnt\system32;c:\jdk1.3.1\bin;
    And I had no problems running java apps from the command line.
    But one day I accidentally looked in c:\winnt\system32 and found (!!!) java.exe and some other files and dlls, which under normal circumstances (may be well, I just didn't know they were installed there) reside in jdk1.3.1\bin. So actually, java.exe from c:\winnt\system32 was executed each time I ran java.exe.
    I checked the versions of both:
    in jdk:
    --- output begin ---
    C:\jdk1.3.1\bin>java -version
    java version "1.3.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
    Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
    --- output end ---
    and in windows:
    --- output begin ---
    C:\WINNT\system32>java -version
    java version "1.3.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
    Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
    --- output end ---
    Looks the same (java.exe files exist in both dirs and they seem to be the same by size and date...
    Ok.
    I checked -help output:
    --- output begin ---
    C:\jdk1.3.1\bin>java.exe -help
    Usage: java [-options] class [args...]
    (to execute a class)
    or java -jar [-options] jarfile [args...]
    (to execute a jar file)
    where options include:
    -hotspot to select the "hotspot" VM
    -server to select the "server" VM
    -classic to select the "classic" VM
    If present, the option to select the VM must be first.
    The default VM is -hotspot.
    -cp -classpath <directories and zip/jar files separated by ;>
    set search path for application classes and resources
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -showversion print product version and continue
    -? -help print this help message
    -X print help on non-standard options
    --- output end ---
    And in windows:
    --- output begin ---
    C:\WINNT\system32>java.exe -help
    Usage: java [-options] class [args...]
    (to execute a class)
    or java -jar [-options] jarfile [args...]
    (to execute a jar file)
    where options include:
    -hotspot to select the "hotspot" VM
    If present, the option to select the VM must be first.
    The default VM is -hotspot.
    -cp -classpath <directories and zip/jar files separated by ;>
    set search path for application classes and resources
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -showversion print product version and continue
    -? -help print this help message
    -X print help on non-standard options
    --- output end ---
    Notice - in c:\jdk "version" of java.exe two more switches exist, namely:
    -server to select the "server" VM
    -classic to select the "classic" VM
    These options do not exist in "windows" java.exe version.
    I suppose, that those "additional" options do not appear, because there is fairly incomplete list of files from jdk1.3.1\bin exists in winnt\system32 - i.e. "dlls" for "server" and "classic" (why for classic) are not available... But I do not know for sure...
    My questions are:
    Is is a normal installation option for either j2ee or j2se?
    If it is, why in the j2se installation instructions they recommend to "correct" the path for "convenience" if in the final account the java.exe from "windows" is called, which well might be really undesired behaviour... (path=c:\winnt;c:\winnt\system32;c:\jdk1.3.1\bin;)
    Where can I read more about this particular situation?
    Thanks a lot guys!

    Is is a normal installation option for either j2ee or j2se?Yes; it is said somewhere in the JRE installation notes. The windoze JRE installer will copy java.exe and javaw.exe (apparently with some other files) to the win dir. You should also find a third java.exe from c:\program files\javasoft\jre\1.3.1\bin or something like that.

  • CLASSPATH and JAVA_HOME commands (variables) aren't recognized by DOS

    My command prompt doesn't recognize neither CLASSPATH nor JAVA_HOME commands...I've already set the path variable "C:\WINDOWS\System32;C:\Programs\Java\jdk1.6.0\bin", but when i'm going to set the classpath and java_home variables it says that they are not recognized as an intern or extern command etc...
    Could anyone please help me?
    (I'm portuguese; sorry for my english...)

    you don't need to set CLASSPATH. you should learn to use -classpath option on javac.exe and java.exe when you compile and run in a command shell.
    if your PATH points to Java's /bin, you probably don't need to do anything else.
    the right way to set environment variables in Windows XP is in the control panel.
    if you want to set them just for one shell, and have them disappear when the shell is closed, you type "set JAVA_HOME=...." and "set CLASSPATH=...".
    You'll find out quickly that CLASSPATH environment variables are ignored by javac.exe, java.exe, every IDE, and every Java EE app server. You have to learn how each one sets CLASSPATH.
    %

  • Setting CLASSPATH and PATH properly how?

    I have set PATH=c:\jdk_install_directory\bin which works fine. However, for example when I create an app or small program for example, simply to print out a line on the screen, it works when I compile in NetBeans. However, if I copy the java file to another directory, my C: root for example, I can compile it, but when I run the class file it gives me errors saying it can't find certain classes. So, I figure its something with the classpath variable that I have to fix. How can I do this properly for both J2SE and J2EE using default install directories for each.
    Thanks so much!!

    Your PATH is exactly what it should be.
    The CLASSPATH answer depends on where you're compiling and running.
    If you're doing things on the command line, I think the right answer is to use the -classpath option on javac.exe and java.exe.
    If you're using NetBeans or another IDE, the right answer is to add JARs and paths according to the idiom demanded by the IDE. Each one is different, and all the ones I know of ignore the system CLASSPATH environment variable. I don't have one set on my machine.

  • Java.exe crash on P4 machine

    Is anyone aware of issues with running jdk1.2.2_008 or later on Pentium 4 machines?
    I installed a app server on Windows 2000 on my home machine and when I try and start it, a Windows popup window appears saying java.exe has generated errors. Where should I look for a more detailed error message?
    The software runs fine on my laptop running 2000 and the only major difference I can think of is the Pentium 4 architecture.
    Any help appreciated!

    Have you found a solution to this problem? I am running java applications on numerous IBM desktops (not P4's)running Windows 2000, but have tried installing JDK1.2.2_006 on a Dell desktop with P4 processor and java.exe aborts with exception nr c0000005 (access violation). I have been cussing Dell, but is it the P4?

  • Problems to invoke java.exe from Java application, but ok for javac.exe??

    How to invoke DOS application from Java application??
    I try the following but it didn't work to invoke command prompt and java.exe, it
    is working to invoke javac.exe. Any ideas why??
    import java.io.*;
    public class CallJavaTest
    { public static void main(String[] args)
    { try
    Runtime.getRuntime().exec("C:\\WINNT\\System32\\cmd.exe"); //doesn't work!!
    Runtime.getRuntime().exec("javac "+ "Test.java"); //it works!!
    Runtime.getRuntime().exec("java "+ "Test"); //doesn't work!!
    catch(IOException e)
    System.out.println(e);

    hi
    String[] cmd = {"cmd","/c", "start",enteryourdoscommandhere};
    Runtime rt = Runtime.getRuntime();
    Process ps = rt.exec(cmd);
    ps.waitFor();
    int ev = ps.exitValue();
    it works for my winXP.
    hope it can helps and not too late ..

  • Java - java.exe (Win2k)

    Hi everyone,
    This is a problem that isn't java-related at all, but it's making me crazy.
    You know how you type 'java' in the console and java.exe gets executed? How can I accomplish that with another file? I would like a 'javah' similarity. I remember you could create aliases in earlier versions of windows, but how can I do it in win2000? It would help me a lot!
    Thanks in advance,
    Nille

    For a file to be executable in the console window, it needs to be an executable format (.exe), or another runnable type (for example, .bat)
    Second, if you want to be able to run it from any directory, you need to include the directory of the file in your PATH variable.
    Right click My Computer > Properties > Advanced > Environment Variables
    You'll probably see c:\j2sdk1.4\bin in there, hence the reason you can run java.exe from anywhere. Simply add your directory and any executable within that directory is able to be ran from anywhere in your command window.

Maybe you are looking for