473,805 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error running program from a remote folder

I haven't programmed in Java for awhile and forgot how to get this to work.

I have a program ListFiles developed in c:\java which lists every .JPG and
..GIF file in a folder. It works fine running from that folder. It takes 1
argument, the pathname, so a command could be "java ListFiles ."

But if I try to run it from another folder, using

"java c:\java\ListFil es ."

then I get an error

"Exception in thread 'main' java.lang.NoCla ssDefFoundError : c:\java
\ListFiles/class"

How can I run this from a folder other than the folder with the .java and
..class files ?
BTW, Here's my code -

===========
import java.io.*;
public class ListFiles {
public static void main(String arg[]) {
/*
** java ListFiles . to list images from the current directory
*/
ListFiles d = new ListFiles();
if (arg.length > 0){
System.out.prin tln("Digital Photo List from " + arg[0]);
d.recurseInDirF rom(arg[0]);
}
}

public void recurseInDirFro m(String dirItem) {
File file;
String list[];
file = new File(dirItem);
if (file.isDirecto ry()) {
list = file.list();
for (int i = 0; i < list.length; i++) {
list[i] = list[i].toLowerCase();
if (!list[i].startsWith("tn _") && (list[i].endsWith(".jpg ") || list
[i].endsWith(".gif "))) {
System.out.prin tln("\"" + list[i] + "\",\t\t\t\ " \",");
}
}
}
}

}
===========
Jul 17 '05 #1
2 3984
Peter Bassett wrote:
I haven't programmed in Java for awhile and forgot how to get this to work.

I have a program ListFiles developed in c:\java which lists every .JPG and
.GIF file in a folder. It works fine running from that folder. It takes 1
argument, the pathname, so a command could be "java ListFiles ."

But if I try to run it from another folder, using

"java c:\java\ListFil es ."

then I get an error

"Exception in thread 'main' java.lang.NoCla ssDefFoundError : c:\java
\ListFiles/class"

How can I run this from a folder other than the folder with the .java and
.class files ?


You apparently aren't familiar with the concept of the classpath. The
classpath tells the JVM where to look for classes. The default class
loader used by the JVM interprets the classpath as a sequence of
directories and/or jar files.

In most environments, you can specify the classpath using the
environment variable CLASSPATH or via the -classpath option to the java
process. In DOS, using what I can glean above, this looks like:

set CLASSPATH=C:\ja va
java ListFiles .

or

java -classpath C:\java ListFiles .

An alternate method is to create an executable jar file. This is really
just a jar file that contains a META-INF/MANIFEST.MF file. The manifest
file must have an entry for the Main-Class. The value of this entry is
the fully qualified class name of the class to execute. Then you could run

java -jar C:\java\ListFil es.jar .

without having to worry about the classpath.

HTH,
Ray
Jul 17 '05 #2
Thanks! I had CLASSPATCH as simply . but now realize that I had to add
this pathname also. Works like a dream!

Pete

Raymond DeCampo <rd******@spam. twcny.spam.rr.s pam.com.spam> wrote in
news:e%******** **********@twis ter.nyroc.rr.co m:
Peter Bassett wrote:
I haven't programmed in Java for awhile and forgot how to get this to
work.

I have a program ListFiles developed in c:\java which lists every
.JPG and .GIF file in a folder. It works fine running from that
folder. It takes 1 argument, the pathname, so a command could be
"java ListFiles ."

But if I try to run it from another folder, using

"java c:\java\ListFil es ."

then I get an error

"Exception in thread 'main' java.lang.NoCla ssDefFoundError : c:\java
\ListFiles/class"

How can I run this from a folder other than the folder with the .java
and .class files ?


You apparently aren't familiar with the concept of the classpath. The
classpath tells the JVM where to look for classes. The default class
loader used by the JVM interprets the classpath as a sequence of
directories and/or jar files.

In most environments, you can specify the classpath using the
environment variable CLASSPATH or via the -classpath option to the
java process. In DOS, using what I can glean above, this looks like:

set CLASSPATH=C:\ja va
java ListFiles .

or

java -classpath C:\java ListFiles .

An alternate method is to create an executable jar file. This is
really just a jar file that contains a META-INF/MANIFEST.MF file. The
manifest file must have an entry for the Main-Class. The value of
this entry is the fully qualified class name of the class to execute.
Then you could run

java -jar C:\java\ListFil es.jar .

without having to worry about the classpath.

HTH,
Ray


Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3402
by: Rocket Hawk | last post by:
Hello All, I am using windows 2000 server IIS 5.0 i was trying to run bat file from asp page and getting: Access Denied but when i run the bat file from the command prompt on the local server, it's running good the bat file copying files from target computer in the LAN to the local computer, o.k
4
11146
by: Stephen Miller | last post by:
Hi, I am running v1.1.4322 on Win2K server and unable to debug a ASP.Net application running locally, using a full URL (ie www.mysite.com). When I hit F5, I get the following error message: <debugger_error_message> Error while trying to run project: Unable to start debugging on the web server. The project is not configured to be debugged.
6
635
by: Javier Cortés Cortés | last post by:
i am getting this error when i am trying to access any file(with the ext. aspx) from my remote server. the error is : Server Error in '/' Application. ---------------------------------------------------------------------------- ---- Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application
0
1725
by: Tony Lewis | last post by:
I'm running IIS on a Windows 2k server and have just installed the .NET framework 1.1 so I can deploy ASP.NET applications on my server through .NET Studios. All my normal ASP applications run fine in IIS but I can't run any ASP.NET pages. Everything in IIS was configured to handle the .aspx file extension by the .NET framework installation and it installed with no errors. When I try to view a simple ASP.NET page through a web browser I...
8
1249
by: John | last post by:
Hi I have a perfectly fine running webform on the local server. When I upload the webform to a remote shared server I get the below error. Any idea what is causing this? Thanks Regards
5
39035
by: Savas Ates | last post by:
I have a web application It works well in my local folder.. When i upload it to my web server i got To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
1
1198
by: ian | last post by:
This morning I upgraded the .net framework on our development web server from 1.1 to version 2.0. Then I ran aspnet_regiis -i from the v2.0 folder. I ran several tests and everything looked OK until I tried running the remote debugger on my machine. I get the following error: Error while trying to run project: Unable to start debugging on the web server. I was able to run remote debugging just fine from my local machine
4
9088
by: lspoulin | last post by:
Hi, We have a webpage browsing folders within the wwwroot. We need to access a remote shared directory the same way. We created a virtual directory in IIS with an alias pointing on this remote directory. The virtual directory is accessible when we type it in the address bar of IE but when we try accessing it with a Scripting.FileSystemObject.
13
3338
by: AAaron123 | last post by:
I downloaded the personal website starter kit and when I run it I get the error shown below. I found a way of using Launch Surface Area Configuration that is supposed to fix the remote setting but I tried it and still get the error. I do not have SQL Server 2005 installed (thought I did once). I do have SQL Server 2008 installed. I don't see anywhere in the code where SQL Server 2005 is referenced.
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.