NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Command Prompt

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Hendorable



Joined: 05 Mar 2017
Posts: 2
Location: Queensland

PostPosted: Sun Mar 05, 2017 9:05 am    Post subject: Command Prompt Reply with quote

I can run programs from command prompt when they are in default package but not when in a created package. java ClassName runs the program in default package. what is the format for programs in created package. Thanks
Back to top
Netinho Teixeira
Posted via mailing list.





PostPosted: Sun Mar 05, 2017 11:43 am    Post subject: Command Prompt Reply with quote

You're doing something wrong. Maybe java path, maybe java call.

Could you pls send your code and the comand?

Sent from my iPhone

Quote:
On 5 Mar 2017, at 06:05, Hendorable <address-removed> wrote:

I have not been able to run programs created with Netbeans to run using command prompt. I have viewed over 100 potential solutions and still the problem persists.

The class file is created ok with javac ClassName.java When I enter java ClassName the message returned is 'Could not find or load the main class'

When I create a project with eclipse I do not get this error and the program runs from command prompt without any errors.

I have uninstalled and reinstalled a few times. A simple "HelloWorld" type program ran ok on one occasion but I cannot repeat that. I just cannot get programs created using Netbeans to run from command prompt. I am using Windows 10 Home and Netbeans IDE 8.2.

Is this a known problem and is there a solution or am I doing something wrong or missing something?

Thanks.



Back to top
Sean Carrick
Posted via mailing list.





PostPosted: Sun Mar 05, 2017 12:49 pm    Post subject: Command Prompt Reply with quote

Typically, even for a simple "Hello world" program, NetBeans creates a JAR file, so you would need to run "just -jar [nameofjarfile]" to execute from the command line.

Get Outlook for Android

From: Hendorable <address-removed>
Sent: Sunday, March 5, 2017 3:05:01 AM
To: address-removed
Subject: [nbusers] Command Prompt


I have not been able to run programs created with Netbeans to run using command prompt. I have viewed over 100 potential solutions and still the problem persists.

The class file is created ok with javac ClassName.java When I enter java ClassName the message returned is 'Could not find or load the main class'

When I create a project with eclipse I do not get this error and the program runs from command prompt without any errors.

I have uninstalled and reinstalled a few times. A simple "HelloWorld" type program ran ok on one occasion but I cannot repeat that. I just cannot get programs created using Netbeans to run from command prompt. I am using Windows 10 Home and Netbeans IDE 8.2.

Is this a known problem and is there a solution or am I doing something wrong or missing something?

Thanks.
Back to top
Papa



Joined: 17 Sep 2016
Posts: 14

PostPosted: Sun Mar 05, 2017 1:44 pm    Post subject: Command Prompt Reply with quote

I am with you on this one bro. I find it a little bit awkward to code
thinking on terminal out put and see a different output; specially for
folks like me, who just arrived in Java-istan coming from a world far
away named C-lious2++. Please Lord NetBeans, not but just one request,
give me terminal output.

Thanks in advance

/* Nothing like having a good night sleep, I feel so relax and playful
Smile */


On 05-Mar-2017 4:05 AM, Hendorable wrote:
Quote:
I have not been able to run programs created with Netbeans to run using command prompt. I have viewed over 100 potential solutions and still the problem persists.

The class file is created ok with javac ClassName.java When I enter java ClassName the message returned is 'Could not find or load the main class'

When I create a project with eclipse I do not get this error and the program runs from command prompt without any errors.

I have uninstalled and reinstalled a few times. A simple "HelloWorld" type program ran ok on one occasion but I cannot repeat that. I just cannot get programs created using Netbeans to run from command prompt. I am using Windows 10 Home and Netbeans IDE 8.2.

Is this a known problem and is there a solution or am I doing something wrong or missing something?

Thanks.



Back to top
Simon Roberts
Posted via mailing list.





PostPosted: Sun Mar 05, 2017 2:02 pm    Post subject: Command Prompt Reply with quote

You're doing it wrong. As Sean points out, you'll typically run the jar file. If not, then you must configure classpath and use the fully qualified name of the main class (i.e. prefix with the package name).

On Sun, Mar 5, 2017 at 8:42 AM, papa <address-removed ([email]address-removed[/email])> wrote:
Quote:
I am with you on this one bro. I find it a little bit awkward to code thinking on terminal out put and see a different output; specially for folks like me, who just arrived in Java-istan coming from a world far away named C-lious2++. Please Lord NetBeans, not but just one request, give me terminal output.

Thanks in advance

/*  Nothing like having a good night sleep, I feel so relax and playful Smile  */


On 05-Mar-2017 4:05 AM, Hendorable wrote:
Quote:
I have not been able to run programs created with Netbeans to run using command prompt. I have viewed over 100 potential solutions and still the problem persists.

The class file is created ok with javac ClassName.java  When I enter java ClassName the message returned is 'Could not find or load the main class'

When I create a project with eclipse I do not get  this error and the program runs from command prompt without any errors.

I have uninstalled and reinstalled a few times. A simple "HelloWorld" type program ran ok on one occasion but I cannot repeat that. I just cannot get programs created using Netbeans to run from command prompt. I am using Windows 10 Home and Netbeans IDE 8.2.

Is this a known problem and is there a solution or am I doing something wrong or missing something?

Thanks.











--
Simon Roberts
Certified Professional Photographer
http://dancingcloudphotography.com
(303) 249 3613
Back to top
Papa



Joined: 17 Sep 2016
Posts: 14

PostPosted: Sun Mar 05, 2017 2:19 pm    Post subject: Command Prompt Reply with quote

Yes, normally the 'jar' file is in 'NetBeansProjects\project_name\dist'.


On 05-Mar-2017 7:47 AM, Sean Carrick wrote:

Quote:

Typically, even for a simple "Hello world" program, NetBeans creates a JAR file, so you would need to run "just -jar [nameofjarfile]" to execute from the command line.

Get Outlook for Android
From: Hendorable <address-removed> ([email]address-removed[/email])
Sent: Sunday, March 5, 2017 3:05:01 AM
To: address-removed ([email]address-removed[/email])
Subject: [nbusers] Command Prompt
Back to top
Hendorable



Joined: 05 Mar 2017
Posts: 2
Location: Queensland

PostPosted: Sun Mar 05, 2017 9:58 pm    Post subject: Reply with quote

Using the feedback here I suspect that is I have been putting unrelated programs in the one package. This seems to be the problem. Might have to do a tutorial on the correct way to file programs.

I suppose with an IDE there really is no need for the command prompt though I wanted to know how to use it.

I can now get programs to run from the default package and from a package I create if there is only one file in the package.


Is there a 'real world' need to use the command prompt to run programs.
Back to top
jeffreycoffield



Joined: 22 Aug 2013
Posts: 10
Location: California

PostPosted: Mon Mar 06, 2017 3:51 pm    Post subject: Command Prompt Reply with quote

You need the command line to run a program automatically from the system
startup or periodically from cron/batch.


On 03/05/2017 01:58 PM, Hendorable wrote:
Quote:
Using the feedback here I suspect that is I have been putting unrelated programs in the one package. This seems to be the problem. Might have to do a tutorial on the correct way to file programs.

I suppose with an IDE there really is no need for the command prompt though I wanted to know how to use it.

I can now get programs to run from the default package and from a package I create if there is only one file in the package.


Is there a 'real world' need to use the command prompt to run programs.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo