Compiling classes in files of a different name

Right I feel liek a right dumbass here but I'm having some trouble.
I want to compile a class in a file of a different name i.e. it's filename for example is Test.java, the class is called class TestWorks and main class is
public class BirthdayProb
     public static void main(String[] args){
     but in the compiler when I type javac TestWorks.java I get a file not found error.
Please help :)

all publicly declared classes must be placed inside a file with the exact same name (case sensitive) as the public class. I.e.
public class Test { } must be placed inside Test.java
public class NumbNuts{ } must be placed inside NumbNuts.java
public class IHateVisualBasic{ } must be placed inside IHateVisualBasic.java
If you want to have more than one class inside of a single file, then only one class may be declared public and the file must be named after said public class:
public class Ned { }
class Dave { }
class Herman {}
class ThisSucks { }must all be placed inside a file called Ned.java
Help?

Similar Messages

  • Save the uploaded file in a different name ?

    Has anyone used the com.oreilly.MultipartRequest Class
    which is used to upload a file to a directory.I am able to that
    fine.I now need a way to save the uploaded file to a different name
    when it gets saved in its destination.I am not sure if com.oreilly.MultipartRequest class has a feature or not.Can
    anyone help me out of this please.

    you can create files with your own name.
    in temp directory, orielly package creates all the files you uploaded from the client.
    create FileInputStream of file you need , create FileOutputStream with your new name and write the content to it.
    here is some code,
    MultipartRequest multi = new MultipartRequest(req,tempUserFile.getAbsolutePath(),100*1024*1024); // current dir
              Enumeration files = multi.getFileNames(); // Collection of files
              // it sends to you with the form
              String fileName=null;
              String name =null;
              while(files.hasMoreElements())
                   name = (String)files.nextElement();
                   File f = multi.getFile(name);
                   fileName = multi.getFilesystemName(name);
                   FileInputStream fis = new FileInputStream(f);
    FileOutputStream fos = new FileOutputStream//create outputstreamwith your new name
    now dump contents of inputstream to outputstream.
    hope this helps.
    raheem

  • Compiling multiple java files present in different packages simultaneously

    Hi,
    I have multiple java files which are present in different folders.
    In some cases, files are importing classes from other packages i.e. some kind of inter-dependency
    How do I compile these java files simultaneously?
    Any help would be highly appreciated.

    Pawan_Anand wrote:
    Hi,
    I have multiple java files which are present in different folders.
    In some cases, files are importing classes from other packages i.e. some kind of inter-dependency
    How do I compile these java files simultaneously?
    Is it circular?
    Thus the dependency is A => B => C => A?

  • Can I get back a file that logic deletes... Well I did but I had thought I saved the file under a different name?

    Hi. I have been using logic pro on the computer at music school... A Mac pro... Anyway, I was recording a friends band. W got some awesome takes down. I was then doing a little post, saved the file as one name and then stared working on it under a new file name. Anyway, logic came up with a splash that asked if I would like to delete the original file, and I clicked yes, as I thought I had saved the session under a different name just earlier. Anyway, I lost everything. Ok... Shirt I thought... But I managed to find everything in the recycle bin. Except one awesome take of an awesome song, I am a little bit heart broken as I've gone though the sessions undo file in quite some detail, but I seem to have lost it. I have access to the file on my Mac at home (MacBook pro, and logic express 8 I think) cool that I can open logic pro files in logic express, but anyway. Anyone want to offer me any solace? I think a solution might be too much to ask for....

    If you were using OSX 10.7 then you could go back to a previous version, but you have overwritten the file.
    Peter

  • Files have a different name on OS 9 and XP

    I copied files on my G4 with OS 9 to a USB stick with FAT32.
    I changed their name on my XP computer.
    When I used the stick on my G4 I saw that the files had the old names.
    When I looked again on my XP computer I saw that the files had the new names.
    How is this possible?

    It sounds like you have apps on your phone purchased with a different Apple ID. If you don't know the password for the Apple ID being displayed for a particular app then you need to delete it and purchase it with your Apple ID

  • Scheduling SQL AGENT JOB for SSAS DataBase to take backup files Daily with Different Names

    Hi All,
    I am working with SSMS. I have Analysis Services DataBase.
    i want to Schedule a SQL SERVER AGENT JOB.
    I want to take that AS DB BackUp Daily and has to be stored in Same
    Folder/same path in my local
    machiene with Different Names.
    Means, There should be Daily BackUps Files in that Path.  According to that we have to Schedule the JOB.
    Can anyone help me for this..
    Thanks,
    Supraja.

     Hi Katherine,
    Thanks a lot for your Response. what
    you have posted is very useful for me.
    But i am searching the result using AS
    DataBase BackUp Script. 
    i found one of the easy way. its working for me.
    Please check the below link for your reference..
    http://dbatasks.blogspot.in/2012/08/taking-backup-of-ssas-database.html
    Thanks,
    Supraja.

  • How to read multiple files of different name using single file adapter

    There are two inbound locations inbound1 and inbound2 , and the files structure present in these two inbound locations are same but the files start with different names example
    (1)files in inbound1 starts with file1,file2...
    (2)files in inbound2 starts with abc1,abc2...
    by using same file adapter with read option how can i read both files....

    Hi K.A.N.N.,
    You can define multiple directories using the above link in 11g and poll for the file as \*.*.
    Alternatively you can use the Synchronous Read and specify the file name at runtime.
    You can also use Pick activity to define multiple branches each with a File Adapter to read from a specified location with specified file name. Although it would contain multiple Adapter Definitions at Development-time, only one of the Adapters will execute at Run-Time.
    Regards,
    Neeraj Sehgal

  • Two separate versions of the same file corrupted in different ways...

    I was working on a Photoshop CS4 file last night that was created in CS4 and has only been opened on this machine in CS4. I saved the file and closed Photoshop. When I open the file today, all my layers are gone, flattened into one Background layer, and the image looks like colored TV static. On top of that, the separate, older version of this file with a different name (created earlier in the week on the same machine in the same CS4) will not open at all - I get the error message, "Could not complete your request because the file is empty" and the file size has mysteriously shrunk to 76 KB from 20+ MB. What happened?! I'm guessing these files are corrupted beyond recovery, but why and how did this happen? Has anyone had this or a similar problem? I want to know how to prevent this from happening in the future. Please help! Thank you. =)

    Thanks for the suggestion, Chris.
    Same issue, new question - don't ask me why I did this, but while both Photoshop and the now corrupted file were open, I changed the name of the folder containing the file, then continued to save the open version of the file without first closing it and reopening it from the newly renamed folder. Could this have caused both files in that folder to become corrupted in different ways? The other file that gives me the "file is empty" error was not open at the time, but it was in that folder. I'm thinking maybe by changing the path to the files while Photoshop was running, that could have triggered this. ?? I have 3 1TB internal drives raided to read as 1 drive, so I'm really hoping that one of these disks is not dying on me as you suggested. I was also backing up an external drive using BackBlaze when this all occurred - any possible connection? How can I find out if one of my three raided drives (and which one) might be going bad?
    Thanks!!

  • Keep getting a read only message and have to save with different name

    I am editing some pdf files, and every time I save I get the message: "The file may be read only, or another user may have it open.  Please save the document with a different name or in a different folder."
    However, when I right click the file and click properties, it is not listed as a read only file.  Nor is the directory read only.   Having to save each file as a different name is driving me nuts.   Is there a fix?

    Is this file saved on a network drive, or a shared folder?
    If so, it's possible someelse in the network has it open at the same time as you.

  • JAXB: Error compiling classes generated by xjc (file name too long)

    Hi friends,
    I am trying to compile classes that are generated by using XJC tool on xsd file. The compilation fails with following message.
    buildxsdmodel:
        [javac] Compiling 794 source files to /home/uchamad/working/teleworker/ejb/build/classes
        [javac] /home/uchamad/working/teleworker/ejb/build/tmpsrc/uk/co/novatel/teleworker/model/wlr/bulksearch
    results/impl/ApplicationInformationTypeImpl.java:58372: error while writing
    uk.co.novatel.teleworker.model.wlr.bulksearchresults.impl.ApplicationInformationTypeImpl.XMLRequestID
    TypeImpl.SearchOrderResultsTypeImpl.SearchTypeDetailTypeImpl.OrderTypeImpl.OrderDetailsTypeImpl.
    OrderLinesTypeImpl.NumberPortingTypeImpl.OLODetailsTypeImpl.NumberLocationTypeImpl.OLOMainP
    STN1AddressTypeImpl.Unmarshaller: /home/uchamad/working/teleworker/ejb/build/classes/uk/co/novatel
    /teleworker/model/wlr/bulksearchresults/impl/ApplicationInformationTypeImpl$XMLRequestIDTypeImpl$S
    earchOrderResultsTypeImpl$SearchTypeDetailTypeImpl$OrderTypeImpl$OrderDetailsTypeImpl$OrderLin
    esTypeImpl$NumberPortingTypeImpl$OLODetailsTypeImpl$NumberLocationTypeImpl$OLOMainPSTN1A
    ddressTypeImpl$Unmarshaller.class (File name too long)
        [javac]                                             public class Unmarshaller
        [javac]                                                    ^
        [javac] 1 error
    The compiler is complaining about the file name being too long. This is happening because the java classes when generated from XSD contains deep nesting of inner classes. So when it comes to compile the .class name file is too long for the operating system.
    I am trying this on unix box.
    I wonder if there is a way to configure XJC so that it does not produce inner classes but instead keep them out.
    Any help would be appreciated.
    many thanks
    Usmangani

    Flattening your schema definition will flatten the output files, too -- that will probably be nice for coding as well since you wont have to use class names such as SomeTypeNestedInAnotherTypeThatHasYetAnotherType. Instead of having all of the elements defined directly within the enclosing root element, define logical chunks at the top level and incorporate them in the definition of real root element of your documents by reference.

  • Save file in different name

    How can I save the screenshot image in different names?
    Example:When button 1 is click save in screenshot1.jpg, then button 1 is click again save in screenshot2.jpg ......etc
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim bmpScreenshot As Bitmap = New Bitmap(Panel1.Width, Panel1.Height - 300, PixelFormat.Format32bppArgb)
    ' Create a graphics object from the bitmap
    Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)
    ' Take screenshot of just the panel control
    gfxScreenshot.CopyFromScreen(Me.PointToScreen(Panel1.Location), New Point(0, 0), Panel1.Size, CopyPixelOperation.SourceCopy)
    ' Save the screenshot
    bmpScreenshot.Save("D:\screenshot.jpg", Imaging.ImageFormat.Jpeg)
    End Sub
    Thanks

    If you only want to number the images like ScreenShot_0000, ScreenShot_0001, and so on...  Then you can use a class scoped integer variable to number them like below.  Also, you can draw the panel directly to a Bitmap without using the CopyFromScreen
    method.
    Public Class Form1
    Private count As Integer = 0
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim bmp As New Bitmap(Panel1.Width, Panel1.Height)
    Panel1.DrawToBitmap(bmp, New Rectangle(Point.Empty, Panel1.Size))
    Dim fn As String = "ScreenShot_" & count.ToString.PadLeft(4, "0"c) & ".jpg"
    Dim saveas As String = IO.Path.Combine("C:\TestFolder", fn)
    bmp.Save(saveas, Imaging.ImageFormat.Jpeg)
    count += 1
    End Sub
    End Class
     However, when you close your application and reopen it again it would start at ScreenShot_0000 again and would overwrite any images that are in that directory that have the same numbered names.  If you want it to automatically detect the last
    numbered file and start with the next number then you can use a While loop in the above code to avoid overwriting the existing images like this.
    Public Class Form1
    Private count As Integer = 0
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim bmp As New Bitmap(Panel1.Width, Panel1.Height)
    Panel1.DrawToBitmap(bmp, New Rectangle(Point.Empty, Panel1.Size))
    Dim fn As String = "ScreenShot_" & count.ToString.PadLeft(4, "0"c) & ".jpg"
    Dim saveas As String = IO.Path.Combine("C:\TestFolder", fn)
    While IO.File.Exists(saveas)
    count += 1
    fn = "ScreenShot_" & count.ToString.PadLeft(4, "0"c) & ".jpg"
    saveas = IO.Path.Combine("C:\TestFolder", fn)
    End While
    bmp.Save(saveas, Imaging.ImageFormat.Jpeg)
    count += 1
    End Sub
    End Class
    If you say it can`t be done then i`ll try it
    Hi IronRazerz,
    Thanks for your solution. I would like to ask you question about open files and rename files, I know that there are out of the question in this thread but the only way I can get the answer through your solution.
    My problem is when I open files "ScreenShot_0000.jpg" and then when I want to rename files the file will rename  "ScreenShot_0001" instant of "ScreenShot_0000.jpg".
    How can I suppose to open and rename files follow by sequence without interrupt?
    Below codes are my modified codes to open and rename files.
    Public Class Form1
    Private count As Integer = 0
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    'rename files
    Dim fn As String = "C:\Users\hwai\Desktop\Capture\ScreenShot_" & count.ToString.PadLeft(4, "0"c) & ".jpg"
    Dim saveas As String = IO.Path.Combine("C:\Users\hwai\Desktop\Capture\", fn)
    My.Computer.FileSystem.RenameFile(saveas, "Rename_" & count.ToString.PadLeft(4, "0"c) & ".jpg")
    count += 1
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    'open files
    Dim fn As String = "C:\Users\hwai\Desktop\Capture\ScreenShot_" & count.ToString.PadLeft(4, "0"c) & ".jpg"
    Dim saveas As String = IO.Path.Combine("C:\Users\hwai\Desktop\Capture\", fn)
    Dim ps2 As Process = Process.Start(saveas)
    count += 1
    End Sub
    End Class
    Thanks

  • Compiling class file to WEB-INF/classes

    I have created 2 source files, viz: DatabaseConnectionBean.java and Agent.java. They both exist in the source directory. In the DatabaseConnectionBean.java I instantiate the Agent.class. When I compile at the Command prompt ... I type javac -d ..\WEB-INF\classes\ Agent.java ... it compiles fine. But when I compile the DatabaseConnectionBean.java by typing javac -d ..\WEB-INF\classes\ DatabaseConnectionBean.java it throws an error.....it cannot resolve symbol 'Agent'.
    I have included the package name, viz: smeyl, in both files.
    A strange thing happens when I type: javac -d ..\WEB-INF\classes\ *.java; at the command prompt...It doesn't throw an error....it compiles both source files....still though my jsp doesn't work properly..so this isn't a solution.
    Please help.
    any help will be appreciated....
    luv
    ushanta

    I'm not to sure myself. I've been using eclipse too long to remember all the intracacies of command line stuff. I know the theory, but am out of practice. :-)
    If you compile DatabaseConnectionBean on its own, I don't think it looks in the destination directory for supporting classes unless you tell it to:
    something like this
    javac -d ..\WEB-INF\classes\ -classpath ..\WEB-INF\classes\;%CLASSPATH% DatabaseConnectionBean.java
    If I'm talking complete rubbish here, someone will kindly (or unkindly for that matter) correct me I am sure

  • UNABLE TO USE  COMPILED CLASSES STORED IN DIFFERENT FOLDERS

    Can you help me out
    i have a problem i have been creating various modules and the compiled classes files are stored in different folders and i want the module to access the compiles classes file from the respective folders can any one give me some idea how to get it working.
    thankyou

    You need to make the folders into packages. Say you have 2 folders, one with your core classes named "core", and one with your GUI classes named "gui". These folders are in a folder called "myprogram". You then put a statement at the top of each file in the "core" folder like this: package myprogram.core; Do the same with all the java files in the "gui" folder as well, but replace .core with .gui. Then, you import your own package the same way you do normal java packages: import myprogram.core.*;
    I hope that makes sense, for more info here is the Java tutorial: http://java.sun.com/docs/books/tutorial/java/interpack/packages.html

  • How to copy a files spotlight comments for an entire folder and place them in a different file with that same name

    I have the same question in a different discussion but I already marked it as solved because one of the questions was answered. Here's the linke to the other discussion if your interested https://discussions.apple.com/thread/5970421 
    I have movie covers saved as a jpeg for every movie my family and I own. There is about 700 and they each have a comment of the main actors, release dates, and descriptions. This makes it easy to find what to watch.Is there an applescript, automator, program I can download,  or program code supported in xcode that will do the following set of inscructions?
    Take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments to a file with the same name but obviously has different extention. For an example
    In a Pictures folder
    Name: Dark Knight, The.jpeg       Comment: (2008) Genre: Action...             <- copy comment
    In a Movie Folder
    Name: Dark Knight, The.m4v       Comment:                                               <- paste
    and do this for all 700 files

    Clendenen02 wrote:
    where should I run the code? in the terminal, or an applescript, or should put it in xcode and run it from there or the terminal.
    What MrHoffman said.
    But if it's easier, you can wrap it in Automator and have Automator ask for the Folders: (Test on a sample of your files before running on all 700 files)
    (do you really own 700 movies??)
    The Workflow is:
    Put this in the Run Shell Script Action (and pass input as arguments":
    PicDir=$1
    MovDir=$2
    for f in $PicDir/*
    do
         if [ ! -d "$f" -a "${f##*.}" = "jpeg" ]; then
              comment=$(mdls -raw -name kMDItemFinderComment "$f")
              if [[ $comment != "(null)" ]]; then
                   picname=${f##*/}
                   movname=${picname%.*}.m4v
                   if [[ -e "$MovDir"/$movname ]]; then
    osascript <<-EOF
    tell application "Finder"
    set comment of file (POSIX file "$MovDir/$movname") to  "$comment"
    end tell
    EOF
                   fi
              fi
         fi
    done
    (BTW, I know that this is a bit of sloppy scripting (wraping an osascript in a Bash Script wrapped in Automator, but it does what you need)

  • Please choose a different name for the file

    How can I stop this message appearning ?

    By choosing a different name for the file?
    You will need to provide a lot more information. 
    What are you trying to do when you see the message?
    What version of Sqldeveloper are you using?
    What operating system are you running on?

Maybe you are looking for