Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How to execute my application from command line
How to execute my application from command line [message #1267564] Sun, 09 March 2014 06:52 Go to next message
ilan sharoni is currently offline ilan sharoniFriend
Messages: 1
Registered: March 2014
Junior Member
i have a java project in Eclipse.
see attached

with CMD, i went to folder: C:\Users\ilan\workspace\test1\bin\test1

and typed the command:
C:\Users\ilan\workspace\test1\bin\test1>java -cp . InsertToFile
Exception in thread "main" java.lang.NoClassDefFoundError: InsertToFile (wrong name: test1/InsertToFile)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)


and got the error above
what can be wrong ?

Thanks
Ilan
  • Attachment: test1.zip
    (Size: 7.54KB, Downloaded 130 times)
Re: How to execute my application from command line [message #1267845 is a reply to message #1267564] Sun, 09 March 2014 17:32 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3298
Registered: July 2009
Senior Member

This is more of a general Java question. The command line is expecting a fully qualified class name, not a file path, to use in conjunction with the classpath you're giving it. In C:\Users\ilan\workspace\test1\bin\, you would run "java -cp . test1.InsertToFile". Once you've gotten this straightened out, you can use Eclipse to Run your Java Application from the UI.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: How to execute my application from command line [message #1790978 is a reply to message #1267845] Wed, 20 June 2018 22:13 Go to previous messageGo to next message
Phuong Tran is currently offline Phuong TranFriend
Messages: 10
Registered: June 2018
Junior Member
Hi, I run eclipse but receiving the following code:

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Can you please help?

Thanks
  • Attachment: 2.jpg
    (Size: 216.28KB, Downloaded 40 times)
  • Attachment: 1.png
    (Size: 163.29KB, Downloaded 35 times)
Re: How to execute my application from command line [message #1790991 is a reply to message #1790978] Thu, 21 June 2018 06:03 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3298
Registered: July 2009
Senior Member

You are not allowed to put new Types in the "java" package. Use a different package name.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: How to execute my application from command line [message #1791007 is a reply to message #1790991] Thu, 21 June 2018 10:54 Go to previous messageGo to next message
Phuong Tran is currently offline Phuong TranFriend
Messages: 10
Registered: June 2018
Junior Member
What new types? I dont get it. I did not put in any new types. I just click next next to install eclipse. The ony thing i added is the path in the environment variables
Re: How to execute my application from command line [message #1791106 is a reply to message #1791007] Sat, 23 June 2018 05:10 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3298
Registered: July 2009
Senior Member

Your class says it's in the package "java". Don't do that.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: How to execute my application from command line [message #1791108 is a reply to message #1791106] Sat, 23 June 2018 10:06 Go to previous messageGo to next message
Phuong Tran is currently offline Phuong TranFriend
Messages: 10
Registered: June 2018
Junior Member
Even i deleted it, it still does not work, please check the list lf error messgae
Re: How to execute my application from command line [message #1791112 is a reply to message #1791108] Sat, 23 June 2018 14:17 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29653
Registered: July 2009
Senior Member
If you deleted it, what do you have left? Show a picture of the open source file and the fully expanded tree in the Package Explorer.
Previous Topic:How to systematically learn and develop plug-ins
Next Topic:"Search text " in selected area only
Goto Forum:
  


Current Time: Sat Nov 17 14:47:00 GMT 2018

Powered by FUDForum. Page generated in 0.03725 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top