Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

running java command

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am in my /work/vsubra/test directory and i have a file here as aigemail.java
Now when i run the javac and java command from this dir everything runs okay.
if i try to run the java command as
java /work/vsubra/test/aigemail then it throws error:
Exception in thread main "no class defn found"
why does it give me error when i try the wholepath.
what is an option if i want to give the whole path?
thanks
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vidhya,
If your file "aigemail.java" is not in a package (i.e. the first, non-comment line in your class starts with "package"), then you run it like this:

Hope this helps you.
Good Luck,
Avi.
 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have mistaken me wrong. This file aigemail.java is in the directory /work/vsubra/test. I would like to execute it from anywhere, so if i have to do that then i will have to specify the full path where the file is. if i give
java /work/vsubra/test aigemail
it gives me an error
Exception in thread main no class found: /work/vsubra/test.
how can i fix this ?
Thanks,
Vidhya
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by vidhya subramaniam:
I think you have mistaken me wrong. This file aigemail.java is in the directory /work/vsubra/test. I would like to execute it from anywhere, so if i have to do that then i will have to specify the full path where the file is. if i give
java /work/vsubra/test aigemail
it gives me an error
Exception in thread main no class found: /work/vsubra/test.
how can i fix this ?
Thanks,
Vidhya


Try
.
If your Java class includes additional APIs, then on Unix machines try -

When you use
[CODEjava /work/vsubra/test/aigemail[/CODE], the Java VM looks for a class in the current directory, with its fully qualified name as
work.vsubra.test.aigemail, which is not present, and that is why the ClassNotFoundError.
-GB.
 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be more specific. My class path is set as
/work/vsubra. I i go to test dir within this dir and run java aigemail, it runs fine but i want to run from my home dir ie /work/vsubra
I tried giving
java -classpath /work/vsubra:/work/vsubra/test aigemail
but still it gives me runtime error.
 
Gopi Balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What packages do the aigemail classes import?
Is aigemail in a non-default pakckage (i.e, is there a package declaration in the aigemail.java file) ?
Try this - java -classpath $CLASSPATH:/work/vsubra/test aigemail
It looks like I added another $ sign previously.
-GB.
 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Balaji... it worked.
 
What's a year in metric? Do you know this metric stuff tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!