JavaScript - Could Not Find The Main Class: Initials.program Will Exit.
Hi everyone!
I'm trying to make this code run and keep getting the same error. "Could not find the main class: Initials. Program will exit." I'm using jcreator and java is up to date. I really not sure if I posted this in the correct area but any pointer will help. I'm a noob at this so thank you anyone who takes the time out to help me. Thanks in advance code i setup: public class Initials { public static void main(String[] args){ } { System.out.println("JJJJJJ FFFFFF"); System.out.println(" J F"); System.out.prinlLn(" J FFFFF"); System.out.println(" J F"); System.out.println(" J J F"); System.out.println(" JJJJJJ F"); } } Errors: --------------------Configuration: Initials - JDK version 1.6.0_21 <Default> - <Default>-------------------- java.lang.NoClassDefFoundError: Initials Caused by: java.lang.ClassNotFoundException: Initials at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: Initials. Program will exit. Exception in thread "main" Process completed. Similar TutorialsHi all we are in desperate need of a solution, we have tried and search different methods but none of us can figure it out. Basically we need to find a word which is inside a class and display a link. So something like this find a word equal to "1 line custom" then display this <a href="/1-line-custom.htm">click here</a> I'm not sure if this is really simple or not. Any help would be much appreciated. Thanks Will I'm currently working on a site with an exit pop asking the visitor, "Are you sure you want to leave?" The problem is that one of the links in the page is triggering the exit pop when it shouldn't be. Here's the code: Code: <a href="intended_next_page.html" class="style4" onClick="ShowExitPopup = false;">Click Here To Continue </a> I know this itself is HTML, but it's related to the exit pop, which is Javascript, so I thought this forum would be the appropriate one. Any idea why this isn't working? I have another link on the page that looks identical (goes to a different page, but that's it), and it's working, but this one isn't. I can't figure it out. Any help is greatly appreciated. Friends, I am looking for a PHP or Java Script to integrete in a PHP CMS, that enables to Redirect to Another URL when the script sense that the visitor is going away from the page. (Hit back button, hit refresh button and so on....) It should be unblockable by browsers. May anyone suggest me one or share the codes. I will use it for personal purpose and not for comercial purpose at all. Thanks I re-wrote this code to display an exit notice alert and open a new window after user confirms they wish to leave the website. However, something is wrong with my code below. The alert and cancel alert works fine, but my new window link does not appear. I was curious if i could get some help fixing this code from anyone in the JavaScript programming forum. See code: <script language='JavaScript'> function ExitNotice() { if(confirm("You are now leaving the web site. To leave our site for the link you selected, click OK. Or Click Cancel to remain. Thank you for visiting our site.")) { return true; } history.go(0); return false; } </script> Now for my button code that appears later inside my form which opens a sized window. <input id="btnView" class="MyButton" type="button" onclick="ExitNotice('http://www.google.com', null, 'left=40,top=100,height=550,width=780, status=no,toolbar=no,menubar=no,location=no, resizable=yes, scrollbars=yes')" name="btnView" value="View Web Site" /> Please test and advise what i'm missing... thanks in advance as i eagerly wait for a solution that fixes this issue. Hello, I'll be honest I dont know much about javascript so hopefully one of you lovely people can help. My issue is I would like to have this code validate my radio buttons on my form and also have an onscreen pop-up in the case that the user is exiting the page without filling out the form. I have had both of these peices of code working...but when I put both of them on the page the pop-up will override the validation script, and I don't wish to have the pop-up, pop-up when the user hits the submit button. Here are my pieces of code: Inside my head tag: Code: <script language="JavaScript"> function closeIt() { return "\n********************************************\nWAIT! WAIT! WAIT! WAIT! WAIT! WAIT!\n********************************************\n\nDon't leave just yet...\n\nDon't worry - We will never rent, sell or\nshare your contact information, with\nanyone else. We respect your privacy\nand hate spam too!\n\n"; } window.onbeforeunload = closeIt; </script> <script language="JavaScript"> function valbutton(thisform) { // place any other field validations that you require here // validate myradiobuttons myOption = -1; for (i=thisform.infusion_option_0.length-1; i > -1; i--) { if (thisform.infusion_option_0[i].checked) { myOption = i; i = -1; } } if (myOption == -1) { alert("You must select an event city date"); return false; } // place any other field validations that you require here thisform.submit(); // this line submits the form after validation } </script> And then for my form and submit code I have: Code: <form name="myform" action="https://mydomain.com/AddForms/processFormSecure.jsp" method='POST' onSubmit="return NoneWithCheck();"> <input id="Submit" name="Submit" type="submit" value="Submit" onClick="valbutton(myform);return false;" /></form> Any help would be appreciated, thanks. Hello, Our website is built in ASP.NET and uses a content management system. The CMS came with a wealth of JavaScript files and I decided to use one of these files for form validation. Although the file is over 2,300 lines, from what I can tell it is supposed to return true if the form is valid and false otherwise. The problem is that a function inside that file seems to get to a certain point, and somehow quit and return true no matter if the form is valid or not. I am calling this JS from an ASP.NET button control. When the button is clicked, a JS function ValidateForm(document.forms[0]) is called. My ValidateForm function calls another function inside the JS file (which calls another, and another...). No matter what, when that second function is called and executed, code execution stops at some point and the form submits (postbacks). I can see that the validation is working just before the postback, but it is not preventing the form from being submitted, and it also stops executing any code after it. Here is my code: ASP: Code: <asp:Button ID="SubmitBtn" runat="server" Text="Submit Form" CausesValidation="false" CssClass="submit_button" OnClientClick="FmValidate(document.forms[0]); return false;" OnClick="SubmitBtn_Click" /> My Javascript: Code: function FmValidate(formObj) { var strError = ''; var e = null; if (strError == '' && 'function' == typeof design_validateHtmlForm) { alert('before'); // this line causes execution to stop - located in external JS file // code states "Returns first invalid element, or null." e = design_validateHtmlForm(formObj); alert("e is " + e); if (e) { strError = e.title; } return false; } } In my ASP.NET button, changing the OnClientClick method to "return false" will prevent form submission, but "return FmValidate(formObj);" will not if that function calls design_validateHtmlForm(formObj). I receive the message box saying "before" but I never receive the second one. I have debugged using Fire bug, but the code seems to cycle through each element on the page and stepping through the code is not realistic (I have done so for 20-minute stretches). I am wondering if anyone has any ideas what code I could look for that would stop execution and return true no matter what, or how I could begin debugging this monster. I was advised by a community member this post would be better suited for the JavaScript section (hope someone can help): The exit pop-up script I have is working fine, other than the fact that it engages on any internal links as well. Below I have the original script I was using along with a modified script sent back to me from someone in another forum. They also advised me to add rel="external" to all of my external links. I'm not sure if a different condition would apply whether the link stayed within my site or went elsewhere. In any event, it's still not working. The changes get me to my desired page on internal links, but the pop-up still engages and I have to click "OK" before it takes me there. I'm obviously looking to get this to work so that all internal links go straight to the page they're defined to, without the pop-up engaging at all. Both script versions are below: My original: Code: <script type="text/javascript"> var internal = 0; function bunload() { if (internal != 1) { window.onbeforeunload = null; alert("******************************************************\n WAIT! WAIT! WAIT! WAIT! WAIT! WAIT!! WAIT!!\n******************************************************\n\nMy partner will probably KICK MY *** for this...\n\nI am secretly giving away a LIMITED number of $20\ncoupons just for Tweeting about us.\n\nIf you act right now, you can grab our Manuscript\nplus ALL Bonuses for just $27!\n\nJust click *CANCEL* on the next window to get your\nV.I.P. discount link!\n\n******************************************************"); window.location = "gift page"; return "******************************************************\n Click CANCEL - Click CANCEL - Click CANCEL \n******************************************************\n\n Click *CANCEL* Now to get your V.I.P. discount!\n\n"; } else { internal = 0; } } if (internal != 1) { window.onbeforeunload = bunload; } else { internal = 0; } </script> And the modified script another community member replied back to use: Code: <script type="text/javascript"> var internal = 0; function bunload() { if (internal != 1) { window.onbeforeunload = null; alert("******************************************************\n WAIT! WAIT! WAIT! WAIT! WAIT! WAIT!! WAIT!!\n******************************************************\n\nMy partner will probably KICK MY *** for this...\n\nI am secretly giving away a LIMITED number of $20\ncoupons just for Tweeting about us.\n\nIf you act right now, you can grab our Manuscript\nplus ALL Bonuses for just $27!\n\nJust click *CANCEL* on the next window to get your\nV.I.P. discount link!\n\n******************************************************"); window.location = "gift page"; return "******************************************************\n Click CANCEL - Click CANCEL - Click CANCEL \n******************************************************\n\n Click *CANCEL* Now to get your V.I.P. discount!\n\n"; } else { internal = 0; } } if (internal != 1) { window.onbeforeunload = bunload; } else { internal = 0; } window.onload = function() { var links = document.getElementsByTagName('a'); for(i = 0 ; i < links.length; i++) { if(links[i].getAttribute('rel') == 'external') { links[i].onclick = function() { bunload(); } } } } </script> Any suggestions on what I'm doing wrong here? My apologies, but my coding isn't very strong and I'm just picking this stuff up as I go. Thanks Hey guys, I'm trying to accomplish something similar to what the develop on this site did: http://backlinkwatch.com/ When you click on the text area, a clickable image, with a 50% black opacity background overlay, and an exit either through a link or clicking outside of the box, shows up. I want to accomplish the same thing, but have the image popup show up on the page load instead of requiring a click of the text area. In addition, I would like this popup only once to each IP address; ie, if you visit a page on my site, this will show up, but if you close it and refresh the page or visit another page on the site a cookie will be stored that knows its already been opened once and it won't try to do it again. Thanks to anyone who can help me with this! Hello, I am new with Javascript and running into this problem that I don't understand. I define a base class that only contains an array "elements", and a derived class that contains nothing more (for simplicity): Code: function baseClass() { this.elements = new Array; } function derivedClass() { } derivedClass.prototype = new baseClass; Then I create two instances of the derived class, and add two elements in each: Code: a = new derivedClass(); a.elements.push("A"); a.elements.push("B"); b = new derivedClass(); b.elements.push("C"); b.elements.push("D"); When I examine the contents of these arrays, I see that both a.elements and b.elements contain {"A","B","C","D"} ! I.e. as if the two arrays are in fact the same array! But these are two separate instances of the class, I expect two separate arrays. Note that if instead I use the base class: Code: a = new baseClass(); a.elements.push("A"); a.elements.push("B"); b = new baseClass(); b.elements.push("C"); b.elements.push("D"); then I get a.elements = {"A","B"} and b.elements = {"C","D"}, as I would expect. Could someone explain to me the problem with using the derived class? Thank you, Stephanos Hi Guys, I have a pop up that opens for a second then hides behind main window for some reason Code: <img src="../../../print_this_page.gif" title="Click To Print This Page" width="64" height="64" onmousedown="MM_openBrWindow('{ads_print_href}?item_id={item_id}','printnew','scrollbars=yes,width=950,height=800')" /> Any ideas what i can add to the code so it stays in top. Works on firefox. Issue is with IE8 Thanks Code: // Form submission $('#contact-form').submit(function() { // Hide any message $('span#contact-msg').css('opacity', 0); // Build data string var fields = [ 'name', 'email', 'message' ]; var data = 'ajax=1'; for (var i = 0; i < fields.length; i++) data += '&' + fields[i] + '=' + encodeURI($('#' + fields[i]).val()); // Submit $.ajax( { url : $('#contact-msg').attr('action'), dataType: 'json', data: data, type: 'POST', success: function(data) { if (data.sent == true) { $('span#contact-msg').html('Thanks for the message. I will get back to you as soon as possible.'); $('#send').css('backgroundPosition', '-207px -168px'); $('#send').attr('disabled', 'disabled'); } else $('span#contact-msg').html(data.error); $('span#contact-msg').animate( { opacity: 1 }, 400); } }); return false; }); I got this code for an contact form, but where can I set the email address to send to? I have a web site application written in VB.net and asp. The main page uses JavaScript to load a popup page that performs multiple tasks. The main page accepts a variety of incoming messages, only SOME of which need to be passed to this popup page for processing. I found an ugly way to pass the message to the popup by placing it in a Session variable. Now I need to cause it to be handled. I see two possibilities, and I do not have a clue how to implement either. Either one would be great: 1. In the main page, trigger a subroutine in the popup, using JavaScript. OR 2. In the popup, establish a trigger any time that Session variable changes. I have an assignment to create a program in JS but I have not read JS much more. So, for this assignment, can anyone help me to solve this assignment? Check attachment. Uploaded with ImageShack.us I need a count down clock that will count down 18 minutes and reset itself at the end. also i need a counter that increases by +1 every 18 minutes starting at 0. thankyou Hello everyone. This is my first program. According to the idea of a program that calculates the sum of savings with the bank interest rates that is paid each year. And I put one amount every month. The question is very simple why full = 0? Code: var years = prompt("How many years will accumulate?)"); var prec = prompt("And how many % bank give?"); var income = prompt("How many you will put off in bank?"); var num = 12; var full = 0; months=years*num; console.log("Altogether we get " + years + " years and " + months + " months.") for (var month = 0; month == months; month++) { if (month % num == 0) { full = full + income + (full*prec/100); } else { full = full + income; } } console.log("Total accumulated =" + full); Reply With Quote 01-24-2015, 04:37 PM #2 leonfresh View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 8 Thanks 0 Thanked 0 Times in 0 Posts var full = 0 declares the variable as an integer variable. it's important to do so to avoid declaration errors. Reply With Quote 01-24-2015, 05:09 PM #3 jmrker View Profile View Forum Posts Senior Coder Join Date Aug 2006 Location FL Posts 3,175 Thanks 39 Thanked 510 Times in 504 Posts You have a logic problem. Try... Code: for (var month = 0; month<months; month++) { Also note that your logic applies the full percentage at the 1st month of the loan/deposit. Is this what your really intended? Reply With Quote Users who have thanked jmrker for this post: Nadir+ (01-24-2015) 01-24-2015, 06:28 PM #4 Nadir+ View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 6 Thanks 1 Thanked 0 Times in 0 Posts i catch another problem, when i change this Code: for (var month = 0; month == months; month++) { on this, Code: for (var month = 0; month<months; month++) { program started work. But in rusults see this . Code: Altogether we get 1 years and 12 months. Total accumulated =01000100100100100100100100100100100100 all code there Code: var years = prompt("How many years will accumulate?)"); var prec = prompt("And how many % bank give?"); var income = prompt("How many you will put off in bank?"); var num = 12; var full = 0; months=years*num; console.log("Altogether we get " + years + " years and " + months + " months.") for (var month = 0; month < months; month++) { if (month % num == 0) { full = full + income + (full*prec/100); } else { full = full + income; } } console.log("Total accumulated =" + full); Reply With Quote 01-24-2015, 06:39 PM #5 Nadir+ View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 6 Thanks 1 Thanked 0 Times in 0 Posts i realized something if i delete var income and just put in its place 100, program work almost normal. Code: Altogether we get 2 years and 24 months. main.js:17 Total accumulated =2520 But if i write 1 year it dont work,how can i fix it? Code: Altogether we get 1 years and 12 months. main.js:17 Total accumulated =1200 Reply With Quote 01-24-2015, 09:42 PM #6 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts The value you get from a call to prompt() is *ALWAYS* a string. When you use the + operator with a string, it does *NOT* do addition; it does string concatenation. You just need to convert all those prompt() results to numbers: Code: var years = Number( prompt("How many years will accumulate?") ); var prec = Number( prompt("And how many % bank give?") ); var income = Number( prompt("How many you will put off in bank?") ); Also, you need to do Code: for (var month = 0; month <= months; month++) { else you will only do (for example) up to month 23 when the user asks for 2 years. Be aware that prompt() and confirm() and console.log() are considered VERY obsolete and should only be used for debugging purposes, not for real web code. This is my code from prelim to finals. The missing part here is when the input is less than or equal to 65 and greater than 100, the prompt will say INVALID ENTRY. However, after it says Invalid Entry, it must ask you to enter again an Entry until you input a valid entry. It must be terminated after you input from prelim to finals either 0,20,30,40 or after you input a valid entry and after the program calculated it. My program does not terminate after I input valid entries. It just continue to ask grade again and again even it already calculated the grades. I don't know how will I put those code inside the program. I'm getting really confused. Code: <html> <head> <title>Web Programming Laboratory Exam</title> </head> <body> <script language="JavaScript"> do { { var pg=prompt('Enter Prelim Grade','0'); if(pg==0) { alert('No Grade'); document.write('<br>Prelim Grade is '+pg); } else if(pg==20) { alert('Not Attending'); document.write('<br>Prelim Grade is '+pg); } else if(pg==30) { alert('Dropped'); document.write('<br>Prelim Grade is '+pg); } else if(pg==40) { alert('Incomplete'); document.write('<br>Prelim Grade is '+pg); } else document.write('Prelim Grade is '+pg); var mg=prompt('Enter Midterm Grade','0'); } { if(mg==0) { alert('No Grade'); document.write('<br>Midterm Grade is '+mg); } else if(mg==20) { alert('Not Attending'); document.write('<br>Midterm Grade is '+mg); } else if(mg==30) { alert('Dropped'); document.write('<br>Midterm Grade is '+mg); } else if(mg==40) { alert('Incomplete'); document.write('<br>Midterm Grade is '+mg); } else document.write('</br>Midterm Grade is '+mg); var fg=prompt('Enter Final Grade','0'); } { if(fg==0) { alert('No Grade'); document.write('<br>Final Grade is '+fg); } else if(fg==20) { alert('Not Attending'); document.write('<br>Final Grade is '+fg); } else if(fg==30) { alert('Dropped'); document.write('<br>Final Grade is '+fg); } else if(fg==40) { alert('Incomplete'); document.write('<br>Final Grade is '+fg); } else { document.write('</br>Final Grade is '+fg); sg=((pg*.3)+(mg*.3)+(fg*.4)); document.write('<br>Your Semestral Grade is '+sg); } } if (sg>=74.5) { document.write('<br>Remarks: Passed'); document.write('</br>This Program is developed by -k3nN'); } else if (sg<74.5) { document.write('<br>Remarks:Failed'); document.write('</br>This Program is developed by -k3nN'); } } while (sg>=74.5|sg<74.5) { document.write('</br>Thanks') } </script> </body> </html> hi i have a html page that has a link "OPEN POP UP" when this link is clicked a new pop up window is opened. and this pop has two LINKS first is ONE and second is TWO. what i want to do is. when any of these LINKS is clicked on the popup the should close and the my main html page from where the popup came should execute a javascript function. please help Friend i concern with some that man told me , JavaScript programming is the best effective for website development. so how it is tell me ?
Hello, glad to be here!! So I am curious about a simple script to play a main video, with thumbnails below. What I am wanting is when you click on a thumb, it plays in the main video spot. Hope this isn't much, but donations are allowed if it is. Im writing this code for a gas station program. I have been writing and improving my code for about 3 weeks now and its quite long. I have about classes , customer class, office class and a gas pumps classes. I need help on how to get started on finding the total output at the end of the day. Conceptually i know what i have to do but I don't know where to begin writing the code. I think each time there is a new customer i should add the amount of fuel purchased to a new total fuel purchases variable in the gas pump class. If any one could give me some advice or tips on my theory it would be great ! Should I create a method or can i be done without one. Code: import java.util.Random; import java.util.Scanner; public class Customer { private String carTag; private double gasPurchased; private int gasType; public Customer () { Random gen = new Random ( ); carTag = ""; for (int i = 1; i <= 6; i++) { //a random number between 48 and 90 int code = gen.nextInt (43)+ 48; if ((code <= 64) && (code >= 58)) { i--; continue; } carTag += ((char)(code)); } System.out.println ("a car arrives; tag number:" + carTag); } public int getGasType () { Scanner inputDevice = new Scanner (System.in); //1:regular, 2:plus, 3:premium System.out.println ("enter type of gas to buy " + "(1:regular, 2:plus, 3:premium): "); gasType = inputDevice.nextInt (); return gasType; } public double getGasPurchased () { Random gen = new Random (); gasPurchased = gen.nextDouble ()* 50; return gasPurchased; } public String getCarTag () { return carTag; } Code: import java.util.Random; public class Office { public static void main (String [ ] args) { double regularTank = 1000; double plusTank = 1000; double primiumTank = 1000; GasPump pump1 = new GasPump ( ); GasPump2 pump2 = new GasPump2 ( ); Random gen = new Random (); //asuumint gas tanks always have gas, will upgrade later do { int whatHappens = gen.nextInt (100); if (whatHappens == 5) { System.out.println ("gas station closed"); break; } else if ((whatHappens % 10) == 0) { if (pump1.pumpAvailable ()) pump1.customerArrival (); else System.out.println ("a new customer arrives at pump 1, but is turned away, gas pump is busy"); } else { if (pump1.pumpAvailable ()) System.out.println ("no customer; waiting........."); } if (!pump1.pumpAvailable()) { if (pump1.updateClock () == 0) pump1.saleComplete (); } } while (true); do system.exit () Code: public class GasPump { final private double REGULAR_PRICE = 3.15; final private double PLUS_PRICE = 3.5; final private double PREMIUM_PRICE = 4.5; final private double HOSE_FLOW_RATE = 0.85; private double totalPayment; private Customer who; private int timeLeftToFinish; private int gasType; private double gasPurchased; private String carTag; public GasPump () { who = null; totalPayment = 0; timeLeftToFinish = 0; } public void customerArrival () { who = new Customer (); System.out.println ("welcome to jack's gas station PUMP 1 "); gasType = who.getGasType (); gasPurchased = who.getGasPurchased (); timeLeftToFinish = (int)(gasPurchased/HOSE_FLOW_RATE); System.out.println (timeLeftToFinish + " total time units needed for this transaction..."); carTag = who.getCarTag (); } private void printReceipt ( ) { System.out.println ("****Sale Receipt"); switch (gasType) { case 1: System.out.println ("regular gas"); break; case 2: System.out.println ("plus gas"); break; case 3: System.out.println ("premium gas"); break; } System.out.println ("gas amount: " + gasPurchased + "\ntotal payment" + totalPayment + "\nthank you"); System.out.println("Pump has " + regularTank()); } private void resetPump ( ) { who = null; totalPayment = 0; timeLeftToFinish = 0; } public int updateClock () { timeLeftToFinish--; System.out.println (timeLeftToFinish + " time units left to finish "); return timeLeftToFinish; } public void saleComplete ( ) { switch (gasType) { case 1: totalPayment = REGULAR_PRICE * gasPurchased; break; case 2: totalPayment = PLUS_PRICE * gasPurchased; break; case 3: totalPayment = PREMIUM_PRICE * gasPurchased; break; } printReceipt ( ); resetPump ( ); } public boolean pumpAvailable () { return (who == null); } } |