Sunday, May 26, 2013

Java Console Application Run Via Cmd - Java | Dream.In.Code


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("

    Emoticons

    "); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 32; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 321810; //]]>

    5 Replies - 58 Views - Last Post: Today, 02:43 PM Rate Topic: -----

    #1 riperator ?Icon User is offline

    Reputation: 0

    • Posts: 9
    • Joined: 19-May 13

    Posted Today, 12:07 PM

    I compiled succesfuly all classes that I have in this project, but than when I tried to run it in cmd with java Main, cmd says:

    Exception in thread "main" java.lang.NoClassDefFounderror: Main

    Is This A Good Question/Topic? 0

    Replies To: java console application run via cmd

    #2 jon.kiparsky ?Icon User is offline

    Reputation: 5440

    • Posts: 8,760
    • Joined: 19-March 11

    Re: java console application run via cmd

    Posted Today, 12:15 PM

    Sounds like java isn't finding a class called Main
    There's a couple of reasons why that could happen. One is that that class just doesn't exist. Another is that it exists, but Java can't find it. If you list the directory you're in, and you see Main.class, please post the code for that class. If you don't see that class, that's probably why you're getting this error.

    This post has been edited by jon.kiparsky: Today, 12:15 PM


    #3 riperator ?Icon User is offline

    Reputation: 0

    • Posts: 9
    • Joined: 19-May 13

    Re: java console application run via cmd

    Posted Today, 12:40 PM

    I type in cmd dir, and it shows me all the classes with .class that I compiled.. Here is the additional report to Exception in thread "main".. i41.tinypic.com/acxwjk.jpg Like what do you think cause problem, imports ? I'm using Netbeans IDE, and pretty much everything shows up and run correctly, but from cmd.. i don't get


    #4 jon.kiparsky ?Icon User is offline

    Reputation: 5440

    • Posts: 8,760
    • Joined: 19-March 11

    Re: java console application run via cmd

    Posted Today, 01:03 PM

    That'll explain it. Netbeans is probably creating packages for your program - this is good practice, but when you're running from the command line, you have to call the class from the right place. A package is a directory - so if you see

    package net.kiparsky.foo

    java will look for these class files under the directory ./net/kiparsky/foo

    So if I try to run a file with that package declaration from the directory it's in:

    
/Users/jon/java/junk:514 $ ls Junk.class  Junk.class [jon: Sat May 25 15:58]  /Users/jon/java/junk:515 $ java Junk Exception in thread "main" java.lang.NoClassDefFoundError: Junk (wrong name: net/kiparsky/foo/Junk) 	at java.lang.ClassLoader.defineClass1(Native Method) 	at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) 	at java.lang.ClassLoader.defineClass(ClassLoader.java:615) 	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 	at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) 	at java.net.URLClassLoader.access$000(URLClassLoader.java:58) 	at java.net.URLClassLoader$1.run(URLClassLoader.java:197) 	at java.security.AccessController.doPrivileged(Native Method) 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [jon: Sat May 25 15:58]  /Users/jon/java/junk:516 $  

    But if I put it in the right directories:

    
 /Users/jon/java/junk:521 $ mv Junk.class net/kiparsky/foo/ [jon: Sat May 25 16:00]  /Users/jon/java/junk:522 $ java net/kiparsky/foo/Junk Hello, World! [jon: Sat May 25 16:00]  

    So what you want to do is look at the package declaration at the top of your source file, and cd up until you're one level outside of that hierarchy. If it's a one-level package:

    
 package foo;

    Then you'll just cd up one level, then run foo/Main

    That should get you there.


    #5 riperator ?Icon User is offline

    Reputation: 0

    • Posts: 9
    • Joined: 19-May 13

    Re: java console application run via cmd

    Posted Today, 01:18 PM

    So I decided to create a new project, with a one level package just like I have in my primary project, and I'm actually inside that one level dir, I type dir to see files, and it shows me HelloWorld.java and HelloWorld.class, than I type in java HelloWorld.. and it's showing me the same exception..??


    #6 jon.kiparsky ?Icon User is offline

    Reputation: 5440

    • Posts: 8,760
    • Joined: 19-March 11

    Re: java console application run via cmd

    Posted Today, 02:43 PM

    Quote

    I'm actually inside that one level dir, I type dir to see files, and it shows me HelloWorld.java and HelloWorld.class, than I type in java HelloWorld.. and it's showing me the same exception..??

    So if you have this code:

    
package hello;  public class HelloWorld{   // nothing surprising here } 

    and you're actually in the directory hello, and you see the HelloWorld.class file, then you need to change directory and go one level up. Then you can run the class with

    >> java hello/HelloWorld


    Page 1 of 1


    Source: http://www.dreamincode.net/forums/topic/321810-java-console-application-run-via-cmd/

    roger goodell psychosis dianna agron million hoodie march tebow trade mike the situation jacksonville jaguars

    No comments:

    Post a Comment