
241 Kan. 555 (1987)
738 P.2d 861
STATE OF KANSAS, Appellee,
v.
WILLIAM MAYFIELD, Appellant.
No. 59,226
Supreme Court of Kansas.
Opinion filed June 12, 1987.
Jim Lawing, of Wichita, argued the cause and was on the brief for appellant.
C. Douglas Wright, county attorney, argued the cause and Natalie G. Wallisch, deputy county attorney, was with him on the brief for appellee.
The opinion of the court was delivered by
HOLMES, J.:
William Mayfield appeals from a judgment denying his motion to set aside a conviction for theft by deception rendered in 1978. The Court of Appeals affirmed the order of the district court in an unpublished opinion. State v. Mayfield, No. 59,226, decided October 30, 1986. We granted appellant's petition for review and we now reverse the decision of the Court of Appeals and the judgment of the district court.
In the spring of 1978, Mayfield was charged with the crime of theft by deception. K.S.A. 1986 Supp. 21-3701(b). At the time of the alleged crime, February 8, 1978, appellant was only seventeen years of age. However, by the time of his arrest, he was eighteen years of age. He was serving in the United States Navy at the time. Mayfield was also charged in a separate case with *556 defrauding an innkeeper. K.S.A. 36-206. At the time of this alleged crime, April 24, 1978, he was eighteen years of age. On July 7, 1978, pursuant to a plea bargain, Mayfield pled guilty to the crime of theft by deception, and the charge of defrauding an innkeeper was dismissed by the State. After serving thirty days of a one-to-ten-year sentence, Mayfield was placed on probation and returned to duty in the Navy. As a condition of probation, Mayfield was ordered to make restitution and pay the costs of the action. On January 11, 1980, the probation was terminated by order of the district court.
On October 18, 1985, Mayfield filed a motion with the district court for an order setting aside the conviction and for dismissal of the action for lack of prosecution. It was the position of the appellant that as he was a juvenile at the time of the alleged crime of theft by deception, the district court had no jurisdiction to charge him with a crime or to accept his plea of guilty to a criminal offense. Mayfield asserted that the court had jurisdiction to proceed only under the Kansas juvenile code, K.S.A. 1977 Supp. 38-801 et seq., and lacked jurisdiction to proceed with criminal charges against him for a criminal violation. The Kansas juvenile code has now been supplanted by the Kansas juvenile offenders code (K.S.A. 38-1601 et seq.).
K.S.A. 1977 Supp. 38-802(b)(1) provided:
"As used in this act, unless the context otherwise indicates:
....
(b) `Delinquent child' means a child less than eighteen (18) years of age:
(1) Who does an act ..., which if done by a person eighteen (18) years of age or over, would make such person liable to be arrested and prosecuted for the commission of a felony...."
K.S.A. 1977 Supp. 38-806(c) provided in part:
"[W]hen any person charged with having committed an act of delinquency before reaching the age of eighteen (18) years is brought before the court after reaching said age, the court shall proceed pursuant to the Kansas juvenile code ...." (Emphasis added.)
K.S.A. 1977 Supp. 38-808 provided a procedure where certain individuals charged under the juvenile code could be prosecuted as an adult. However, such procedure was not followed here.
It is conceded by the State that at all times relevant herein *557 Mayfield was charged as an adult pursuant to the criminal code and proceedings were never commenced pursuant to the Kansas juvenile code. When Mayfield appeared before the district court on July 7, 1978, the court started the hearing by inquiring:
"THE COURT: ... How old are you, Mr. Mayfield?
"THE DEFENDANT: Eighteen.
"THE COURT: Eighteen?
"THE DEFENDANT: Yes, your Honor."
It appears that no one thought to inquire of the defendant as to his age on February 8, 1978, the date the alleged crime was committed. The record is silent as to any knowledge by the Court, State, or defense counsel that defendant was a juvenile when the alleged crime occurred. It is interesting, however, that while the record does not disclose the actual facts upon which the charge of theft by deception was based, the State's brief reads:
"The Police reports regarding the Theft by Deception showed that on February 8, 1978, the Defendant had informed the victim, Mr. John Swisher, owner of Swisher TV and Appliance Center, that he was 19 years old. The Defendant also completed an application for credit on or about February 8, 1978. On this application, Mr. Mayfield listed his age as 18. Based on this information, the State of Kansas filed criminal charges in the District Court against the Defendant." (Emphasis added.)
Thus, it appears the charge was based upon the defendant's obtaining merchandise on credit by misrepresenting himself to be an adult. If, indeed, that was the basis for the original charge, the State must have known Mayfield was not eighteen years of age when the alleged crime occurred. We will not speculate further on that apparent inconsistency.
The district court and the Court of Appeals both found that Mayfield had waived any objection to jurisdiction. The Court of Appeals stated:
"We are satisfied that a juvenile who misrepresents his age or intentionally withholds this information from the district court hearing the criminal charges waives the right to be heard in juvenile court."
The court then cites several decisions from other jurisdictions as support for its statement. While it is true a juvenile may waive certain rights, such a waiver must be made knowingly and voluntarily. State v. Muhammad, 237 Kan. 850, 703 P.2d 835 *558 (1985). Suffice it to say, there was absolutely no evidence that Mayfield misrepresented his age to the court, intentionally or otherwise. He answered all questions propounded to him truthfully and there is no showing that he knew of his rights under the Kansas juvenile code, that he intended to waive personal jurisdiction, or that his defense counsel knew he was a juvenile at the time of the alleged offense. We find no basis for a conclusion that Mayfield had waived his rights under the Kansas juvenile code or waived personal jurisdiction.
The Court of Appeals also found that the district court had subject matter jurisdiction because the alleged offense was a felony. We do not agree that because the offense is categorized as a felony under the criminal code that the court obtained subject matter jurisdiction. At the outset we note that subject matter jurisdiction cannot ordinarily be waived. In In re Estate of Freshour, 177 Kan. 492, Syl. ¶ 3, 280 P.2d 642 (1955), we held that "[j]urisdiction of the subject matter of an action is vested by statute and cannot ordinarily be conferred on a court by consent, waiver or estoppel."
In 1985 Mayfield was charged in the United States District Court for the District of Kansas with several counts of federal firearms violations based upon his possession of firearms after having been convicted of a felony. The underlying felony supporting those charges was the conviction in 1978 of theft by deception. After being advised of the facts surrounding this conviction, Judge Kelly, in a well-reasoned opinion, stated:
"K.S.A. 38-815(e) requires that whenever a person 18 years of age or older is taken into custody for an alleged act committed prior to the time the person reached 18, the law enforcement officer shall refer the matter for proceedings pursuant to the juvenile code. According to K.S.A. 38-806(a), proceedings concerning any `delinquent child' (defined in K.S.A. 38-802(b) as a child less than 18 years old who does an act which would be punishable as a felony under the criminal code) are to be governed by the provisions of the juvenile code. Under 38-808(b), a person between the ages of 16 and 18 must be prosecuted under the juvenile code unless a hearing is held on motion of the district attorney and the court finds the child is not a `fit and proper' person to be dealt with under the juvenile code. It is clear that unless the 38-808(b) procedure is followed, the district court has no jurisdiction to try the child under the criminal code.
"In State v. Chatmon, 234 Kan. 197, 671 P.2d 531 (1983), the Kansas Supreme Court held that in any criminal action the trial court must have jurisdiction over the offense charged and that a judgment rendered with lack of jurisdiction is *559 void. The Chatmon court relied on State v. Minor, 197 Kan. 296, 300, 416 P.2d 724 (1966), wherein it was stated, `This court has repeatedly held that a judgment which is void for want of jurisdiction may be attacked at any time and may be vacated because it is a nullity.'
"Based on the foregoing Kansas statutes and cases, this Court finds the Cowley County District Court lacked jurisdiction to convict Mayfield under the Kansas Criminal Code, and therefore, the 1978 conviction of theft by deception is void ab initio." United States v. Mayfield, 628 F. Supp. 1515 (D. Kan. 1986).
The learned trial judge then dismissed the federal charges which were dependent upon prior conviction of a felony. We agree with Judge Kelly's analysis of the jurisdictional issue in this case. Although the decision of the federal district court has now been reversed on other grounds, the federal appellate court also appears to have recognized that Mayfield's conviction in 1978 in Cowley County District Court was void for lack of jurisdiction. United States v. Mayfield, 810 F.2d 943, 944 (10th Cir.1987).
In the early case of State v. Dubray, 121 Kan. 886, Syl., 250 Pac. 316 (1926), the court held:
"On September 28 a boy who became sixteen years old on June 3 was arrested for statutory rape committed on May 27, all in the same year, and was brought before a justice of the peace. At a preliminary examination the boy's age was disclosed, and the justice of the peace transferred the case to the juvenile court. The juvenile court referred the case to the district court for trial, a jury impaneled by the district court found the boy guilty, and the district court sentenced him on the verdict to the reformatory. Held, the district court had no jurisdiction to pronounce sentence on the verdict."
Justice Burch, writing for a unanimous court, stated:
"The legislature intended that police officers, constables and sheriffs, police courts, justices of the peace and district courts, and everybody else concerned with the consequences of breaches of the criminal law, should get it completely out of their minds that a delinquent child is to be regarded or treated as a criminal. A violation of law, which if committed by an adult would be rape, is not a crime if committed by a boy under the age of sixteen years. It is an act of delinquency. Whether an act constitute delinquency or crime is determined by the factor of age. So determined, the character of the act is fixed, remains constant, and, if delinquency, does not enlarge to crime by lapse of time. The juvenile court has exclusive jurisdiction over delinquencies (State v. Dunn, 75 Kan. 799, 90 Pac. 231; Swehla v. Malone, 114 Kan. 712, 220 Pac. 299); and the juvenile court does not lose jurisdiction by delay in obtaining personal jurisdiction over the delinquent, whether the delay be occasioned by failure to discover the delinquency, neglect or inability promptly to institute delinquency proceedings, or deliberate postponement of delinquency proceedings with a view of invoking the criminal law.

*560 `The statute defines a "delinquent" child to be one who, of the ages specified, commits any of the acts named, including the crime charged here, and then vests in county courts of the state exclusive jurisdiction to try such "delinquent" children. They become "delinquent" children by the commission of the act denounced, when the acts are committed, and the jurisdiction then vests exclusively in the county court, which court having thus acquired exclusive jurisdiction cannot be ousted by its failure to act. The very purpose of this law, as has been declared by this court upon more occasions than one, is to provide for the protection and care of juvenile offenders in a humanitarian effort to prevent them from becoming outcasts and criminals, rather than to inflict punishment for their delinquencies. To hold that the officers charged with the execution of the law may defer action until the offending child has passed the age thus protected by the statute, and then prosecute him as a criminal and not as a juvenile, would defeat the very purpose of the law, and cannot be sanctioned.' (Mattingly v. Commonwealth, 171 Ky. 222, 224.)" 121 Kan. at 895-96.
In State, ex rel., v. Owens, 197 Kan. 212, 416 P.2d 259 (1966), the juvenile judge of Sedgwick County asserted that certain sections of the Kansas juvenile code were unconstitutional. Among the provisions of the code alleged to be unconstitutional was that subjecting youths sixteen and seventeen years of age to the juvenile code. The Supreme Court described at length the provisions of the code, its background, and its objectives, and referred repeatedly to the exclusive original jurisdiction of the juvenile court. The court stated:
"So long as the proceeding in the juvenile court is in the nature of a protective proceeding entirely concerned with the welfare of the child, and conforms to the substantive requirements of essential due process, there is no constitutional shortcoming. The whole design of the juvenile law is to avoid charging the juvenile offender with crime, thus making inappropriate application of the criminal laws of the state. The breadth of the court's authority to deal with juveniles is matched by a corresponding breadth of responsibility to protect the minor's interests. The validity of the whole juvenile system is dependent upon its adherence to its protective, rather than its penal, aspects." p. 223.
In State v. O'Keith, 136 Kan. 283, 15 P.2d 443 (1932), the defendant, thirteen years of age, was arrested in 1919 and charged with burglary and grand larceny and five days later pled guilty. In 1931, a motion was filed to set aside the judgment of conviction. The court stated:
"A district court in this state is altogether without jurisdiction to deal with delinquencies of infants under sixteen years of age. It is the deliberate policy of this state that infants of tender years, however erring or wayward they may be, shall not be regarded as criminals or dealt with as such." p. 285.
*561 Numerous earlier cases are cited in the opinion. For a more recent discussion of jurisdiction in juvenile cases, see State v. Lowe, 238 Kan. 755, 715 P.2d 404 (1986).
Although, since court unification in 1977, we no longer have separate juvenile courts, the policy adopted by the legislature and consistently recognized by the courts has not changed. The jurisdiction of the district court over juvenile offenders in 1978 was based solely upon compliance with the provisions of the Kansas juvenile code and today is based solely upon the provisions of the Kansas juvenile offenders code. (K.S.A. 38-1601 et seq.)
K.S.A. 1977 Supp. 38-801 (now K.S.A. 38-1601), provided in part:
"This act shall be liberally construed, to the end that each child coming within its provisions shall receive such care, custody, guidance, control and discipline, preferably in the child's own home, as will best serve the child's welfare and the best interests of the state. In no case shall any order, judgment or decree of the district court, in any proceedings under the provisions of this act, be deemed or held to import a criminal act on the part of any child ...."
Thus, we think it is abundantly clear that the Kansas juvenile code (and now the Kansas juvenile offenders code) established an exclusive procedure for those subject to its provisions and the district court did not have jurisdiction of the subject matter of the action against appellant. To obtain such jurisdiction the proceedings had to be instituted under the provisions of the Kansas juvenile code as it existed in 1978. Failure of the State to proceed in accordance with the code deprived the court of jurisdiction to accept appellant's attempted plea of guilty to a crime when the acts complained of were done by appellant at a time when he was under the age of eighteen. The district court and the Court of Appeals were in error in concluding that as the acts of Mayfield would have constituted a felony if he had been an adult, the court had jurisdiction of the subject matter. The subject matter of the action was not a criminal prosecution for a felony but a juvenile proceeding which was never commenced pursuant to the juvenile code.
The decision of the Court of Appeals is reversed, the judgment of the district court is reversed, and the case is remanded with directions to set aside the conviction.
