Running java program from DOS
I have just installed JDK 5.0 (update 4) and have tried writing a small demo program. The .class module is created ok but when invoking java I get "Exception in thread "main" java.lang.NoClassDefFoundError. I am running java from a DOS batch file with one command of c:\progra~1\java\jdk15~1.0_0\java %1. A similar batch file is used to invoke javac which works.
Any ideas what I'm doing wrong? Thanks.
You can't run a Java program from DOS, in fact you can't even install a JRE under that old operating system as Java requires a 32 bit or 64 bit operating system architecture which DOS never offered.
But on the off chance you mean a command prompt from Windows...
Check your classpath, most likely you forgot to add the current directory to that.
Similar Messages
-
How to run java program from website?
Hello
I'd like to know how to run java program from my web page.
I'd like to push some button in this web page so java program that would be on my server
would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
CheersI rather thought about RMI. But I could try servlets. So how it would look like?.
I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
Message was edited by:
macmacmac -
Win2000 NoClassDefFoundError running java.exe from DOS prompt
I am using Windows 2000 with J2SE v 1.3.1_02 and have a problem when I run java.exe from the command line for classes that are defined to be in a package. I can both compile and run this program from the TextPad editor but when I run it from a DOS prompt I get the error "Exception in thread "main" java.lang.NoClassDefFoundError: MyClass"
My CLASSPATH is set to D:\
The files MyClass.java and MyClass.class are in the directory D:\MyProject
here is the source:
package MyProject;
public class MyClass
public static void main(String[] args)
System.out.println("MyClass main");
Note that if I comment out the package statement and add "." to CLASSPATH then it runs from the DOS prompt. Why does the program run from inside TextPad but not from the DOS prompt? Seems to be some type of bug in java.exe on Windows 2000 when the keyword package is used.It turns out that if you use the main method in a class that declares the package statement you need to use the fully qualified name to run the program. Using this statement works for this problem:
java MyProject/MyClass
the forward slash is required even though is a Windows system. -
How to run java programs from a master java program?
Hello,
I have several java programs which run from the command prompt. I am seeking help with code for starting java programs from within a java program. For example, a program called master.java works something like this:
import java.*;
create connection pool
create variables and result sets
start/run slave1.java (var1, var2);
start/run slave2.java (var3, var4, var5);
start/run slave3.java (var1, var4);
end of program master.java
Each of the slave.java programs will run for up to an hour. I do not want the master.java program to pause for each slave program to stop. Instead, the master program will keep running and multiple slave programs will be running simultaneously with the master program. When a slave program starts, it is on its own. Also, if possible, I would like to have each of these slave.java programs open in a new separate command window, so I can observe each slave program running in separate windows.
Any suggestions for code or helpful documentation are greatly appreciated.
Thank you,
LoganThank you all.
At the bottom of master.java I have successfully started a batch file with these lines:
String jcmd = "cmd.exe /c start c:/data/simulations/MsgViewCount2.bat";
Process proc = Runtime.getRuntime().exec(jcmd);
But I still cannot get a java program to start. Here is one variation I have tried:
String [] cmdArray = new String[2];
cmdArray[0] = "java";
cmdArray[1] = "slave1";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmdArray);
This compiles, and no errors occur, but nothing happens.
Regarding this comment:
Why Runtime.exec? Either make the slaves Runnable or
just call their main() methods.
Oh, I see. Sepearate output. :PNone of the slave.java programs have any output.
Thanks again. -
Running java command from DOS prompt
Hi,
When I run java from the DOS prompt (NT) in any other location than the JDK bin directory, I get the following error:
Error opening registry key 'Software\JavaSoft\Java Runtime Environment'
My understanding is to be able to run this from anywhere you need to add the tools.jar file to the CLASSPATH, which I have done.
There is no entry in the Registry for Software\JavaSoft...etc, has anyone any idea what my problem is and how I can solve it?
Thanks in advanceHi,
I am running Java 2 SDK, Standard Edition Version 1.2.2 running on NT. It was installed as part of Oracles JDeveloper IDE and is running on NT.
All I want to be able to do is run java from the command line e.g. 'java myclass', to run a standalone Java program. I can run 'javac myclass.java' to compile the program without any problems, but my understanding is that to do this all I need is to have the '.../java1.2/bin' directory included in the 'PATH' variable, whereas to run the java runtime you need to include the tools.jar in the CLASSPATH variable.
As I said previously I can run the 'java myclass' command from the '../java1.2/bin' directory, just not from anywhere else. As for whats in the code, does not matter you should be able to type just java on the command line and it will come back with an error prompting for the class name. Here is an example of what happens:
I:\>java
Error opening registry key 'Software\JavaSoft\Java Runtime Environment'
However if I change to the correct directory, I get:
D:\oracle\JDev32\java1.2\bin>java
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] jarfile [args...]
(to execute a jar file)
where options include:
-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
-? -help print this help message
-X print help on non-standard options
The contents of my PATH and CLASSPATH variable are shown below, Thanks again.
I:\>PATH
PATH=D:\oracle\BIN;D:\oracle\Apache\Perl\5.00503\bin\mswin32-x86;C:\Program Files\Oracle\jre\1.1.7\b
in;D:\oracle\ora8i\bin;C:\DMINT40\Win32\Bin;C:\WINNT\system32;C:\WINNT;C:\Program Files\Symantec\pcA
nywhere;d:\oracle\jdev32\java1.2\bin;d:\downloads\oraxml\bin;d:\oracle\jdev32\java1.2\lib\tools.jar
I:\>echo %CLASSPATH%
d:\oracle\jdev32\java1.2\lib\tools.jar;d:\oracle\apache\apache\htdocs\web-inf\classes;d:\oracle\apac
he\jserv\servlets -
Run java program from start menu
Does anyone know how to write a class so that when a user is running my program for the first time they can run an installation file that will put a shortcut to my bat file in the start menu.Know of any place i can get info on setting up an installation class or something similar.
If you could give me some info would greatly appreciate it,it's my first time doing anything this big and not really sure where to start with writing an installation fileIf your program is just for windows then giving the user an exe instead of a .bat file will help.
http://www.rolemaker.dk/nonRoleMaker/javalauncher/marner_java_launcher.htm
Your user will either need to have a JVM installed on their machine or you will need to provide one with the application. If you intend to provide one, the licence doesn't allow you to install it on to the target machine, but you can place the java dir in your directory structure and access the java/javaw command by a relative path (see the help on the above site for that)
Once you have a directory structure set up for your application, you can use any comercial intall program to give give you a setup.exe file or whatever. if you are providing the VM with your distribution, then the file will at least 14MB plus your class and resource files. If you read the licence agreement for distributing the VM, it tell you what files can and can't be removed from it to make the file a bit smaller. For instance, you can remove webstart because you won't be using that.
search http://www.download.com/ for installers. I think there are a few ad supported ones if you don't want to pay -
Running Java program from script shell using SSH
Hello!
I have this problem: I need to run a java command like: java Prog arg1 arg2 arg3 on i machines, using a shell script.
First of all, I'm trying to make it work for a single machine. But the problem is when I write the line << ssh user@localhost "java -classpath /a/b/ Prog arg1 arg2 arg3" >> and run the script, it is not able to execute the entire line. Is there a special options for the arguments of my Prog class? I want to mention that between my arguments there is another text file which is read by the Prog and when i run the script says it cannot find that file; Please any ideas for not remain stuck here?
Thank You in advance!Hello! Thank you for being so helpful..
The part with << is not existent in my script, I've put it just here for quotation.Sorry
So, from the terminal under Linux I run the command like this: I go to my folder where I have all my .java Classes and I execute the command java Prog arg1 arg2 arg3 . Where arg1...arg3 are arguments which are read from the terminal and then used in my Prog. One of the arguments is a text file, from which Prog.java reads line by line it's content. How can I run the same thing , under a script using SSH? This is basically my question, taking into consideration what I've written in my first post. -
Can't run Java Programs from home computer
Hi, sorry if this is a simple problem.
I downloaded Java version 1.4.0_03 but can't get it to work. I have configured the PATH variable and the CLASSPATH but it isn't working.
If I type java -version the right stuff comes up.... so where have I gone wrong?
Any ideas much appreciated
Thanks
catI downloaded JDK
this is whats in the PATH variable:
;C:\Program Files\Java\j2re1.4.0_03\bin
and in the CLASSPATH:
.;C:\Program Files\PhotoDeluxe HE 3.0\AdobeConnectables;C:\Program Files\Java\j2re1.4.0_03\lib\tools.jar -
How to Set up the variables and others to compile and Run Java Programs
Hello,
I have just downloaded the jdk1.6.0_07 and jre1.6.0_07 and installed it in C:\Program files\Java in my Windows XP ,So please tell me how to sett up the enviroment variables etc to compile and run Java Programs from Command Prompt.
thanksTo set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:
1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
2. Click Advanced > Environment Variables.
3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:
C:\Program Files\Java\jdk1.6.0_<version>\bin -
hi,
I have VC++ code.
I want to run java program from VC++ (SDK).
Can I call it?
plz help it's urgent....
thanks in advance...We do it all the time using the JNI invocation API (this is actually how the java.exe application works).
Here's a tutorial I just found (not sure how good it is, but it should get you going):
http://www.inonit.com/cygwin/jni/invocationApi/
One note: If you are going to be invoking the JVM from different threads in your native app, there is some special handling you will have to do - the above tutorial doesn't address this scenario (a dig through the JNI docs should help with that one, though).
Cheers,
- K -
Running a java program from an icon
I want to run my program from an icon on my desktop. I have a .bat file that I've built a shortcut to and it works.MY GUI program does display and run when I click on the icon. The problem is that the DOS window also shows up behind my GUI.
Is there anyway to prevent the DOS window from showing? Or is there another way to run a Java program without resorting to a DOS command line or running it through FORTE or another IDD?Chris's solution worked well, with one small problem. Once my GUI starts, it takes up the whole screen. Normally when I run it, it appears as a small window.
not a big problem, I can reduce it easily after it starts. But does anyone know a way to make it come up in the reduced size it norally comes up in when I run it from my IDE? -
URGENT: How to run a Java program from a different directory?
Hi.
How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
What would be the command to run the Java file from c:\Java.
I can't remember it and I need it asap.
Cheers.If the class you are trying to run is MyApp.class, try
c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)". -
Can we run EXE file/ Another Java Program from Java Application? How?
Can we run EXE file and another java program from java application?
Thanks in advanceExample running adobe acrobat
String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
Runtime rn = Runtime.getRuntime();
Process process = rn.exec(command);
process.waitFor();rykk -
how do i launch one Java program from another?
both .class files and the JRE directory are in the same directoryYou can use Runtime.exec() to run it as a seperate process, or you can always instantiate your secondary class. Do a search on the term "runtime.exec()" befure you go spawning another thread asking how to use it. That particular subject has been done to death many times already.
-
I want to run this program from my java code,
In Linux(ubuntu) I write this command to open the program window
$ paraFoam -case /home/saud/OpenFOAM/OpenFOAM-1.5/run/tutorials/icoFoam/cavity/In my java code I wrote it like this("/home/saud/OpenFOAM/OpenFOAM-1.5/bin/" is the path of the program):
String command = "/home/saud/OpenFOAM/OpenFOAM-1.5/bin/paraFoam " +
"-case /home/saud/OpenFOAM/OpenFOAM-1.5/run/tutorials/icoFoam/cavity/";
final Process myProcess = Runtime.getRuntime().exec(command);
BufferedReader buf = new BufferedReader(new InputStreamReader(
myProcess.getInputStream()));
String line;
while ((line = buf.readLine()) != null) {
System.out.print(String.format("%s\t\n", line));
buf.close();
int returnCode = myProcess.waitFor();
System.out.println("Return code = " + returnCode); Return code = 0
but the program is not opening
Edited by: Saud.R on Apr 11, 2009 3:37 AMWelcome to the Sun forums.
I am not sure of the answer to your question, but people who use Processes regularly, warn other users to ensure they are also doing something with the error stream of the process, otherwise it can hang as you describe.
Maybe you are looking for
-
I have to keep going to disk repair to correct an issue that makes my monitor go to sleep the message i get is Permissions differ on "System/Library/PreferencePanes/.Displays/V1/Displays.prefPane/Contents/Resourc es/pt.lproj/DisplaysPref.nib"; should
-
SQLNET authentication problem!
Hi, We have a setup in which the database server is running on a 'XXX' domain and all the clients are running in domain 'YYY'. On the client, if following is the setup, then the clients face ORA-03113 after around 45 to 90 minutes of idle time. SQLNE
-
HT4914 will I need to upgrade my icloud storage capacity to hold my entire music library?
Will I need to upgrade my iCloud storage capacity to upload my entire music library into the itunes match?
-
Further to installing OS X 10.8 Mountain Lion, the tabs on Firefox become unresponsive if I try clicking on them further to my Macbook Pro going into energy saving (sleep) mode.
-
Invoking Sqlplus without "as sysoper"
On the database server how do I connect without using "as sysdba" or "as sysoper" when I invoke sqlplus. the below does not work [oracle@dev1 ~]$ sqlplus hr/blah SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 4 17:30:04 2009 Copyright (c) 1982,