How can I split a class into 2 files?

I converted a C++ program to Java recently and it works fine, but I ran into a problem.
One file is very large and I need to add more functionality. Unlike with C++ where you can just put new functions in another file, I don't see a way to do it in Java.
I made another file, and therefore another class, but the compiler complains that it can't call a static function from non-static context. (I did not declare it static so I guess it's assuming it) But I understand why. So I made the new class "extend" the old one so "this" would exist but that doesn't work -- Is it because the new class is a subclass of the original class?
There must be a way to do this. But I don't see what is likely obvious. HELP! And thanks.

JavaIsBetterThanCPP wrote:
There must be a way to do this. But I don't see what is likely obvious. HELP! And thanks.Unfortunately Java has no concept of "partial classes" like C# has. Generally, however, a class that is large enough to split up into separate files is either one class that should be modularized further into separate classes, or it already is modularized and all that code is the result of many inner classes. What some people do is promote those inner classes to top-level members in their own file, and mark them as package-private. Using a package you can basically have two classes that know everything about each other and have full access to each other.
But personally, and until I see justification otherwise, semantics in Java being unbreakingly tied to a certain file structure and naming is the most bonehead and, frankly, non-Java thing about Java.
There's probably a pre-processor out there that will let you split a class into multiple files and will combine them into a single source file just-in-time to pass to the compiler.

Similar Messages

  • How can i split a library into two.. i no longer want to sync all of my wifes songs and apps.. i have a separate account, but want to take my music and apps from hers so i now have my own and she has her own.. so that syncing is easier

    how can i split a library.. my wife and i used to share it, but now we have our own id's.. i want my music and apps off of hers so that i can sync my phone and only my music and apps will "come over"

    how do i share then? can she upload music if we share it somehow?
    If so how??
    i am also having the same problems now with IPhoto, she has all of her/our pics in my IPhoto library.
    I have told her that now i have bought her the Ipad she would have to log into her user, the only thing is there is no music in her itunes account nor photos in her I Photo library, i have spent all day trying to find a way to "share" but no luck,
    Please help i`m going mad!
    Surely we could just share these...?
    I need step by step instructions please someone send me a link on "how to share pics and music!"

  • How can I split a waveform into chunks at each sawtooth?

    I have spent a lot of time trying to tackle this problem and hope someone can offer a useful insight!  I have attached the VI described here.
    I am using Labview connected to a NI USB-6212 DAQ to create a voltage ramp, which drives a laser through its scan.  The laser is pointed at a detector, and I simultaneously read in a signal from that detector using the same DAQ. Because the detector is illuminated by the laser, it shows the scan ramp.  I would like to repeat this voltage scan and read-in indefinately.  Much of this system is working.  I have used the "RampPattern.vi" to create a sawtooth wave, which is output successfully to the DAQ.  As expected, the input from the detector shows the same sawtooth pattern.  However, I am having a lot of trouble managing and displaying the scanned sawtooth from the detector, which is currently read in as a waveform.
    The challenge I can't seem to get around is manipulating or collecting the sawtooth in such a way that I can do two things:
    1)  Display the incoming sawtooth a 'tooth' at a time.  Each sawtooth represents one laser scan, and I would like to see the incoming scan ramp as a single slope, not a series of sawtooths.  Ideally,as each scan came in, it would replace the prior scan (as in the Labview 'graph'), so that the plot would show a motionless scan that would flicker up the input of the last scan.
    2)  Split the incoming sawtooth at each ramp into an ever-updating array that could be acted upon with the math functions, saved to a file, etc.
    I have the feeling that this wouldn't even be a speedbump for an experienced user, but I have been hung up on it.  Could I collect the incoming analog signal from the detector in chunks that are the length of each ramp?  Could I trigger an event at each ramp that would split off the waveform into an array?
    I am open to any suggestions!  Thank you for the input and help,
    Sam
    Solved!
    Go to Solution.
    Attachments:
    scancode_topost.vi ‏129 KB

    Problem solved!
    The solution was to wire the "number of samples per channel" setting in the DAQMx Read VI.  I set the 'number of samples per channel' to the number of points in each sawtooth scan (that is the same value as 'number of samples in waveform' used to generate the sawtooth in BasicFunctionGenerator.vi).
    The DAQMx Read Analog VI now reads one sawtooth at a time.  The Waveform Graph displays each sawtooth, one at a time, as captured.  The output waveform also has the proper dimensions (the length of the scan) and I can perform math operations on each single scan.
    Works great! I have posted the operational code.
    Attachments:
    fullsimulation_20101208_newramp.vi ‏131 KB

  • How can I embed album artwork into files in bulk?

    I am using iTunes 11.1 and have imported a bunch of CDs.  The artwork is associated the album in iTunes, but I would like to embed the artwork ino each song file.  I know how to do it one album at a time, but I am wondering if there is a way to have the artwork embedded into multiple albums (or all) at once.
    Oh, I am running iTunes on a Windows machine.
    Thanks,
    John

    If iCal can not publish a calendar, then with or without iWeb, the calendar is not available.
    Find another calendar, such as Google's :
    http://www.google.com/search?q=google+calendar
    Edit :
    http://www.google.com/search?q=html+calendar

  • How can i split a 700 mb file?

    i need to split it into 7 parts, 100 mb each. please help. didn't have the patients to learn how to use winrar on a mac(it should be graphics instead of command only) but don't have the patients for that. thanks.

    to clarify i've already zipped it, but its a AVI file

  • How can i split my catalog into two

    I am using PSE 11 would like to take 31,000 files from the main catalog and put them in a separate catalog.  The files are all in a directory tree called Digital Scrapbooking which has 1,728 folders and 31,000 files. Is there a simple way of doing this?  Alternatively would putting these files into an album achieve a similar effect?
    Another problem I have is I would prefer the organiser to open with the directory tree showing as the default rather than the list of folders it shows at the moment.  Is that possible?
    Thanks in advance for any help or suggestions.

    Thanks for the input folks.  I do a lot (and I mean A LOT) of digital scrapbooking.  The files I want to put into another catalogue are all related to this.  They are digital papers, elements, backgrounds, textures, masks etc saved as layered .psd, .png, .jpg formats.  They are not photographs per se.  I did have them in a separate catalogue at one stage but combined them when PSE11 catalog would do it's own thing but now with >30K scrapbooking files and >25K of photographs the catalogue is just too cumbersome and time consuming to 1. load and then 2. change to the directory tree I prefer to work with.
    In case you haven't guessed I really dislike this version of the catalogue I much preferred version 9 and I don't want to go to version 12 and find I have similar or more problems.  If I could use PSE without involving the catalogue at all  I would but some things just have to be done through it which is a real pain in the butte.

  • How can I split a signal coming in from an instrument​?

    I have a device (USB-TC made by Measurment Computing Corporation) that reads in 3 thermocouples in real-time and sends the information to my computer via USB. I am getting one signal from the instrument, how can i split it up into each thermocouple's information in LabVIEW 7.1?
    Cory K

    You are going to have to clarify what you mean by 'one signal'. If you can specify a multi-channel acquitisiton, then you should be getting back at least an array where each element in the array represents a channel. If you are specifying a single channel and getting back a scalar, you would need to call that three times with a different channel each time.

  • HT201066 How can I split a long recording audio file into multiple audio files?

    Hi,
    How can I split a long recording audio file into multiple audio files?
    With Windows I was using Nero software, which is not available for Mac. Is there any similar app for free for Mac?
    Thanks!

    Hello ingiorgio
    You can import the track into GarageBand and then split the tracks there. Once that it is done you can highlight the ruler section and then share the song to iTunes to get them separated out. 
    GarageBand - Split regions in the Tracks area
    http://help.apple.com/garageband/mac/10.0/#gbnd76fcce04
    GarageBand - Share songs to iTunes
    http://help.apple.com/garageband/mac/10.0/#gbndfb96a96f
    Regards,
    -Norm G.

  • How can I split a pdf file into smaller files using Acrobat XI

    How can I split a pdf file into smaller files using Acrobat XI?

    Hi laforcej
    Open the PDF In Acrobat ...
    Go to Tools -> Pages -> Extract
    Now Select the Page Number you Want to Extract and Save them

  • A pdf file failed to convert to word, presumably because of size.  how do i split a large pdf file into manageable secrtions?

    I'm running Abode Reader XI version 11.0.7.  Repeated attempts to convert a large (439 page) file, a dissertation, failed.  How do I split a large pdf file like this into manageable sections for conversion?

    Hi Mike,
    Your 11MB file is well within the file-size limits for ExportPDF, but depending on the number of pages, complexity of the file (and yours doesn't sound complex), and your connection speed, it is possible that the service is simply timing out before it can finish processing. These steps can help:
    If the file already contains editable text (that is, it isn't a scanned document), try disabling OCR as outlined in this this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel.
    Clear the browser cache and try again.
    Try a different browser.
    Let's start there. If you still can't export the file to Word, let me know and we'll take it from there.
    Best,
    Sara

  • How can I split a QuickTime file in two?

    8/21/2006. How can I split a QuickTime file in two? I saved a two hour videotape converted by PYRO A/V LINK to iBook G4 combo into a file of 24.5 Gb, and I saved to QuickTime into 536 mgs. Of course, it took half a day. When I went to copy it as video (536 mgs) onto a CD of 700 mg capacity, Toast 7 said it required 1100 mgs and couldn't do it. I have QuickTime Pro, got just recently. I would be very happy to learn how to split it, so to copy each of the split pieces onto 2 CD's, for my own purposes. Many, many thanks. Chuck Yopst. [email protected] 847-394-5621 Moutn Prospect, IL (nw Chicago suburb)

    Wednesday, 10:35 am CDT, 30 August 2006
    Kirk, Thanks for your post Monday 8/21. Interesting how things worked out. I split the OuickTime file--of my retired uncle Church of the Brethren pastor's 50th wedding anniversary, and came up with two folders. Each contained four more folders, and inside folder Mvseg was file Avseq.dat which contained the video material and, when double clicked, started playing that half of the story on Windows 98SE. It just so happens that my uncle's PC operating system is a Windows 98SE. All this from QuickTime 7.0 which Windows 98SE would play the audio but not the video. Then a week later, yesterday in fact, in looking through iDVD help I found your solution, which heretofore I had no idea of. I had to go into System Preferences--Hardware--CDs & DVDs, and set these for "Open with 'Ask what you want to do'." The factory settings were to "open these when inserted" without that "Ask"ing. So then I was able and did follow your solution and it worked, but as a single QuickTime file, playable on Windows XP and Windows 2000 and Macintosh but not Windows 98SE. So everything worked out well. And thank you again. Chuck Y

  • How can i write a string into a specified pos of a file?

    How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
    for example:
    the content of file is:
    name=123
    state=456
    i want to modify the value of name with 789
    (write to file without read all file into ram)
    How can i do it? thank you

    take this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
    import java.io.*;
    import java.util.*;
    * Copyright (c) 2002 Frank Fischer <[email protected]>
    * All rights reserved. See the LICENSE for usage conditions
    * ObjectProperties.java
    * version 1.0, 2002-09-12
    * author Frank Fischer <[email protected]>
    public class ObjectProperties
         // the seperator between the param-name and the value in the prooperties file
         private static final String separator = "=";
         // the vector where we put the arrays in
         private Vector PropertiesSet;
         // the array where we put the param/value pairs in
         private String propvaluepair[][];
         // the name of the object the properties file is for
         public String ObjectPropertiesFileName;
         // the path to the object'a properties file
         public String ObjectPropertiesDir;
         // reference to the properties file
         public File PropertiesFile;
         // sign for linebreak - depends on platforms
         public static final String newline = System.getProperty("line.separator");
         public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
         //     System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
              this.ObjectPropertiesFileName = ObjectPropertiesFileName;
              this.ObjectPropertiesDir = ObjectPropertiesDir;
              // reference to the properties file
              PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
              // vector to put the param/value pair-array in
              PropertiesSet = new Vector();
         //     System.out.println("Properties File Backup wird erzeugt: "+name);
              backup();
         //     System.out.println("Properties File wird eingelesen: "+PropertiesFile);
              try
                   //opening stream to file for read operations
                   FileInputStream FileInput = new FileInputStream(PropertiesFile);
                   DataInputStream DataInput = new DataInputStream(FileInput);
                   String line = "";
                   //reading line after line of the properties file
                   while ((line = DataInput.readLine()) != null)
                        //just making sure there are no whitespaces at the beginng or end of the line
                        line = cutSpaces(line);
                        if (line.length() > 0)
                             //$ indicates a param-name
                             if (line.startsWith("$"))
                                  // array to store a param/value pair in
                                  propvaluepair = new String[1][2];
                                  //get the param-name
                                  String parameter = line.substring(1, line.indexOf(separator)-1);
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  parameter = cutSpaces(parameter);
                                  //get the value
                                  String value = line.substring(line.indexOf(separator)+1, line.length());
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  value = cutSpaces(value);
                                  //put the param-name and the value into an array
                                  propvaluepair[0][0] = parameter;
                                  propvaluepair[0][1] = value;
                             //     System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
                                  //and finaly put the array into the vector
                                  PropertiesSet.addElement(propvaluepair);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   // System.out.println("in ObjectProperties");
         // function to be called to get the value of a specific paramater 'param'
         // if the specific paramater is not found '-1' is returned to indicate that case
         public String getParam(String param)
              // the return value indicating that the param we are searching for is not found
              String v = "-1";
              // looking up the whole Vector
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = new String[1][2];
                   // trying to get out the array from the vector again
                   s = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we look up the value and write it in the return variable
                        v = s[0][1];
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // giving the value back to the calling procedure
              return v;
         // function to be called to set the value of a specific paramater 'param'
         public void setParam(String param, String value)
              // looking up the whole Vector for the specific param if existing or not
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we remove the param/value pair so we can add the new pair later in
                        PropertiesSet.removeElementAt(i);
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // if we land here, there is no such param in the Vector, either there was none form the beginng
              // or there was one but we took it out.
              // create a string array to place the param/value pair in
              String n[][] = new String[1][2];
              // add the param/value par
              n[0][0] = param;
              n[0][1] = value;
              // add the string array to the vector
              PropertiesSet.addElement(n);
         // function to save all data in the Vector to the properties file
         // must be done because properties might be changing while runtime
         // and changes are just hold in memory while runntime
         public void store()
              backup();
              String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
              try
                   //opening stream to file for write operations
                   FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
                   DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
                   // looping over all param/value pairs in the vector
                   for (int i=0; i<PropertiesSet.size(); i++)
                        //the String i want to read the values in
                        String s[][] = new String[1][2];
                        // trying to get out the array from the vector again
                        s = (String[][]) PropertiesSet.elementAt(i);
                        String param = "$"+s[0][0];
                        String value = s[0][1];
                        outtofile += param+" = "+value+newline;
                   outtofile += newline+"#end of file"+newline;
                   try
                        PropertiesDataOutput.writeBytes(outtofile);
                   catch (IOException e)
                        System.out.println("ERROR while writing to Properties File: "+e);
              catch (IOException e)
                   System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
         // sometimes before overwritting old value it's a good idea to backup old values
         public void backup()
              try
                   // reference to the original properties file
                   File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
                   File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
                   //opening stream to original file for read operations
                   FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
                   DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
                   //opening stream to backup file for write operations
                   FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
                   DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
              //     String content = "";
                   String line = "";
                   // do till end of file
                   while ((line = OriginalFileDataInput.readLine()) != null)
                        BackupFileDataOutput.writeBytes(line+newline);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   System.out.println("this is a serious error - the server must be stopped");
         private String cutSpaces(String s)
              while (s.startsWith(" "))
                   s = s.substring(1, s.length());
              while (s.endsWith(" "))
                   s = s.substring(0, s.length()-1);
              return s;
         public String createDate(String seperator)
              Date datum = new Date();
              String currentdatum = new String();
              int year, month, date;
              year = datum.getYear()+1900;
              month = datum.getMonth()+1;
              date = datum.getDate();
              currentdatum = ""+year+seperator;
              if (month < 10)
                   currentdatum = currentdatum+"0"+month+seperator;
              else
                   currentdatum = currentdatum+month+seperator;
              if (date < 10)
                   currentdatum = currentdatum+"0"+date;
              else
                   currentdatum = currentdatum+date;
              return currentdatum;
         public String createTime(String seperator)
              Date time = new Date();
              String currenttime = new String();
              int hours, minutes, seconds;
              hours = time.getHours();
              minutes = time.getMinutes();
              seconds = time.getSeconds();
              if (hours < 10)
                   currenttime = currenttime+"0"+hours+seperator;
              else
                   currenttime = currenttime+hours+seperator;
              if (minutes < 10)
                   currenttime = currenttime+"0"+minutes+seperator;
              else
                   currenttime = currenttime+minutes+seperator;
              if (seconds < 10)
                   currenttime = currenttime+"0"+seconds;
              else
                   currenttime = currenttime+seconds;
              return currenttime;

  • How can I hide the class file ??

    Hi !
    I has a question, when i write a program of Java, then use the command "javac" to compiler to class file for other people using, but the class file can be disassembled and convert to source code. How can I hide the class file and let people can not disassemble, or can not see the source code. Thinks

    See these....
    http://www.saffeine.com/
    http://www.jarsafe.com/
    I recently read this. This will help you.
    http://developer.java.sun.com/developer/qow/archive/160/index.jsp
    Enojy....
    Rajesh

  • How can I convert a class file to Exe file

    hai
    How can I convert a class file to Exe file

    Please search the forums before asking questions - this has been answered hundreds (really!) of times.

  • How can I import a movie into iMovie 09 from a hard drive?  The movie will open and play in idvd but breaks into separate files that can't be downloaded when I try to import.  Can it be done?

    How can I import a movie into iMovie 09 from a hard drive?  The movie will open and play in idvd but breaks into separate files that can't be downloaded when I try to import.  Can it be done? I am trying to create a disc of player highlights for a collegiate coach, and I am using movie files downloaded to my hard drive from a DVD created on a PC. 

    No unfortunately it won't open in quicktime either.  It does the same thing that Imovie does, separates it into two file folders audio and video, and if i select video it opens to reveal 8 files that cannot be selected.  VIDEO_TS.BUP, VIDEO_TS.IFO, VIDEO_TS.VOB,VTS_01_0.BUP, VTS_01_0.IFO, VTS_01_1.VOB, VTS_01_2.VB, VTS_01_3.VOB.  All of which cannot be opened or selected.
    Opening it in Idvd and folllowing your suggestion works and I get a format code of NTSC.  Is that the same?  Thank you for your time and response.
    CaCanuck

Maybe you are looking for

  • Can't override DNS Server settings - can only append!

    See this thread for a similar question: http://discussions.apple.com/thread.jspa?messageID=3555096 I have also filed this with Apple (Problem ID 5159216). Here is the text of the report (with a few bits removed - not crucial to understanding the repo

  • Mac Mini with Dell Monitor

    I just bought my dad a Mac Mini and gave him my big Apple Monitor (can't remember size but bigger than a small TV:). Well dad says the monitor is too big and wants to use his Dell monitor. I called support and for the first time I couldn't understand

  • Problem in editing a java file in Webdynpro

    Hi All, I have created a new dc and checked it in the DTR. Now, when I sync it from DTR, and again try to change the implementation of the view, it does not let me do it. I have to go to DTR>inactive dcs-> and explicitly edit the file. I am able to c

  • Does anyone know what screen tone should be?

    I received a replacement phone yesterday. It has a warmer, deeper tone than the phone I got on Wednesday which has a cooler, more blue tone. I was satisfied with the replacement, but I have had several people tell me it has a problem. They tall me it

  • Package of Lightroom 5 and Camera Raw 8 ?

    I heard that the Camera Raw 8 is supported the RAW file of some aged Leaf Digital Back, is that mean if I buy a Lightroom 5, the Camera Raw 8 is included in the package?