How to put the ".class" file in Memory with Javac?

The J2SE 6 RC have an tool : javax.tools.JavaComplier. I can use it to compile the source code in memory( I implemented an JavaFileObject).
But the compiler aways put the output file(.class) to file system. It;s not my want to do . I am writing an IDE ,I use javac to determine the code error after the user's typing. So complier is used a lot , writing to file system is a time consuming job.
I also want to use the byte code(".class" file) for reflection , so if the JavaCompiler can put the output file in memory and then I can reflect it.
My current solution is puting the output file to file system then use Class.forName() to reload it in memory then reflect it. It seems a useless IO operation with file system.
How can I do with it?
Thanks!

Those 'useless' I/O operations are one or two out of thousands that are implied by compiling a Java source file.
I wouldn't worry about it.

Similar Messages

  • How to get the .class file for the extended Controller .java file

    Hi,
    I did the below steps.
    1. Created New OAWorkspace
    2. Created New project
    3. Imported the page .xml file
    4. Added new .java file by extending the controller class
    5. Added code in the .java file.
    6. Ran the .xml file
    As I copied all the folders from Unix box, the page was opened.
    But My question was where can I see the .class file the extended controller. It's a .java file. How to compile and get the .class file for this .java file. If I get this .class file, I can go to the page and click the personlize page. and change the Controller name to the new path by ftp ing the new class to the cust.oracle.apps.pos.changeorder.webiui.
    Please let me know how to create the .class file.
    Thanks,
    HP

    All are Java files are stored in JDEV_INSTALL_DIR:\jdevhome\jdev\myprojects\
    In your case the path java would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myprojects \cust\oracle\apps\pos\changeorder\webui\
    AND
    Once you compile the java file in Jdeveloper, Class files get generated @ below path
    In your case the path of class would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myclasses \cust\oracle\apps\pos\changeorder\webui\
    Duplicate Thread-
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • How to protect the class files inside jar file.

    Hi Group,
    pls help me.
    my need is i created a executable jar file with certain classes.
    and i'm supposed to send it to my client.
    but if the client needs he can extract the class files from the jar and with the
    help of some decompilers he can convert class file to .java source code and read the whole
    stuff.
    how can i protect my jar file from these.
    is there any security mechanism for that
    pls help me.
    Regards,
    Ranjith.M

    In order to protect my jar file I tried the jar signer technology but it only protects the jar from modification so I need to know how to protect jar file from decoding of the contents inside.

  • How to make the class files to run in a particular platform only

    Class files which are created from the java files should only run on a particular platform only..say i'm going to create the class files for windows environment then those class files should only run on that environment only. it should not run on unix environment etc..how to do this..

    hi,
    i cant think of a reason why you would do something like that.. You cant prevent your class files to be read by the JVM of a different OS, but anyway you could do something to stop your code from running in a different OS, for eg.
    Properties prop = System.getProperties();
    if (prop.getProperty("os.name").startsWith("Windows")==true)
          //code
    else
           System.out.println("Sorry i will not run in this OS");
    }cheerz
    ynkrish

  • Where to put the class file

    i am using tomcat 4.1.27 server and i created a UserData.java file as a bean; i have placed the class file in the WEB-INF/classes folder. still i get the following error:
    ==============================================================
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 21 in the jsp file: /ics334/Javanese/name7.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\ics334\Javanese\name7_jsp.java:60: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.name7_jsp
    UserData user = null;
    ^
    An error occurred at line: 21 in the jsp file: /ics334/Javanese/name7.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\ics334\Javanese\name7_jsp.java:62: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.name7_jsp
    user = (UserData) pageContext.getAttribute("user", PageContext.SESSION_SCOPE);
    ^
    An error occurred at line: 21 in the jsp file: /ics334/Javanese/name7.jsp
    Generated servlet error:
    C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\ics334\Javanese\name7_jsp.java:65: cannot resolve symbol
    symbol : class UserData
    location: class org.apache.jsp.name7_jsp
    user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
    ^
    3 errors
    Apache Tomcat/4.1.27
    ===============================================================
    the structure of the jsp file is as
    <%@ page contentType="text/html" %>
    <%@ page import="java.sql.*,java.util.*" %>
    <%@ page import ="javax.servlet.*"%>
    <%@ page import ="javax.servlet.http.*"%>
    <html dir="rtl">
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>
    <body>
    <p dir="ltr">
    <jsp:useBean id="user" class="UserData" scope="session"/>
    <jsp:setProperty name="user" property="*"/>
    <font size="5">Your Name is :<%= user.getUsername() %> <BR></font>
    </p>
    </body>
    </html>
    can anyone help plz?

    I am also facing the same problem. Try placing ur
    class files in tomcat's /common/classes folder.
    Sometimes it works. How ever it did not work in my
    case. Hope it works in your!!This ain't a right way of doing it... when creating a web-app, the files should be contained in it.
    The problem is can be resolved by packaging the class in say beans. Then place that class in WEB_INF/classes/beans.
    Cheers!
    ***Annie***

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • How to protect the .class files from decompilers

    Hi all,
    I have developeed an application and I want it to be protected from the decompilers. The problem that I am facing now is that the .class files can be ripped by using the decompiling softwares.
    It will be great if any body cvan bail me out of this.
    Thanks
    kvmp

    Obfuscating your files is your best bet. This has been discussed to death, both here and on every other Java-related discussion site and newsgroup since about 1996; a Google search on "Java obfuscation" should help.
    You can also look here for an overview:
    http://mindprod.com/jglossobfuscator.html#OBFUSCATOR
    Grant

  • How to generate the ATR files for reports with out manually?

    Hi all,
    how to create the ATR files for reports in OBIEE 11g with out manually?
    is there any other method to create the ATR files by using the OBIEE Server?
    please provide me the solution for this?
    we are creating manually for each and every report, it is time taken process how can we generate ATR files automatically
    by using the OBIEE Server?
    Thanks,

    Hi,
    I am afraid not.ATR are attributes files contains the object's full name, access controllist (ACL), description, and so on.Each catalog object has a corresponding attributes file, I am not sure why do you have to generate the atr files.In case you need info about atr files: http://businessdecisionsystems.com/blog/?p=7
    If you have huge number of similar reports(with filter variations and same kind of layout), try to play around with the xml to minimize the development effort.
    Rgds,
    Dpka
    Edited by: Dpka on Oct 4, 2011 12:00 AM

  • How to restrict the .class file from decompilation

    Hi all,
    i got a security problem. i need all the java class files to be most secured. is there any to restriction on the java class files from decompilation. is that possible?. pls help me out. it's very urgent
    thanks in advance

    You can make it harder to understand the decompiled code if you use an obfuscator. (I don't have links to any, do a google search, or search these forums, it have been discussed here previously.)
    You cannot completely prevent decompilation, though. Obfuscating does not for example not mean that any passwords you have hardcoded in the source is secure.

  • I don't understand how to put the core files on usb stick

    I read the instructions here  http://wiki.archlinux.org/index.php/Ins … _USB_stick but I am not sure how to do this I tried this way ( using cmd prompt on winxp x64) dd if=C:\Documents and Settings\Administrator\My Documents\Torrents\archlinux-2008.06-core-x86_64.img=/dev/sd[F]
    but I get an error saying that dd is an unrecognized command, I have also downloaded Flashnul but I am not sure how to use it if I type in anything I cannot execute it because as soon as I push the enter key Flashnul quits. so could someone explian to me how to do this please

    jo3 wrote:
    dd is a unix command.
    I have not used flashnul in a while so IIRC first plug in your usb stick and type "flashnul -p" at a command prompt to get a list of devices. Then type "flashnul flash_device_number -L archlinux-2008.06-core-x86_64.img" to copy the img to the device.
    HTH
    -jo3
    hank you for your reply.
    Well  Iguess flashnul isn't working properly because when I type in "flashnul -p" it just quits.
    I installed Cygwin and have tried to install it that way but I was getting errors saying no such file or dir.
    Well it ended up being that my usb stick was "f: I kept trying dd if=archlinux-2008.06-core-x86_64.img of=\\.\f:Kingston"and not  "f: I kept trying dd if=archlinux-2008.06-core-x86_64.img of=\\.\f"
    I am thinking that the The Cygwin Way
    Make sure your cygwin installation contains the dd package.
    Place your image file in your home directory, in my case it is:
    C:\cygwin\home\John\
    Run cygwin as administrator (required for cygwin to access hardware). To write to your USB drive use the following command:
    dd if=image.img of=\\.\[x]:
    where image.img is the path to the img file within the cygwin directory and \\.\[x]: is your USB device where x is the windows designated letter, in my case "\\.\d:".
    Note: This will irrevocably delete all files on your USB stick, so make sure you don't have any important files on the stick before doing this.
    should say that for noobs like me

  • How to customize the class files needed to run webcam applet client side?

    Hi... Each time i try to transmit the stream to client, i got the following error in my Apache log file:
    File does not exist : javax
    File does not exist : jmfsample
    File does not exist : media
    I've customized the jar file using customizer and it does not help at all.
    Could anyone please help?
    All helps are appreciated.
    Thanks.

    You can't delete it. I wouldn't worry about it at this point. I'm just taking a guess here that you would like to execute a method, then stop execution of the method. The thing to do is forget about writing code for a minute. You know how to execute methods, right? So the tricky part is 1) getting it to stop and 2) knowing whether it's running (or maybe you don't need to know) and 3) knowing whether you should stop it or start it. For number 1, it's pretty easy if the method is running over a loop some number of times. Each time through the loop, have the method check for a stop condition that you can set elsewhere. If it's not doing a loop, you (or some kind soul) will have to come up with something else. I'll let you work on 2 and 3.

  • Delete last line of a textfile without putting the whole file in memory

    Hello!
    I want to delete the last line of a text file without loading the whole text file into thememory. My problem is as follows:
    A algorithm generates output that has to be written into a text file. This happens periodically - the output goes straight into a xml file. The xml file looks like this:
    <test>
    <step>
    <time>2006-06-19 10:55:20</time>
    <result>12321</result>
    </step>
    <step>
    <time>2006-06-19 10:58:20</time>
    <result>41515</result>
    </step>
    </test>
    The XML file must be valid, so I have to delete the last line ("</test>") before I add a new <step>-section.
    Many thanks in advance
    Kind regards,
    buliwyf

    For processing in a separate tool which understands XML, then using a DTD to declare an external entity is often better - you wrap the entity in the document root element, so you can just append to the end of the file the entity references and not bother about inserting before the closing tag.
    File other app loads:
    <?xml version="1.0"?>
    <!DOCTYPE test [ <!ENTITY content SYSTEM "content.xmlfragment"> ]>
    <test>&content;</test>File content.xmlfragment which can be simple appended to:
    <step time="2006-06-19 10:55:20">12321</step>
    <step time="2007-04-09 10:55:20">12321</step>
    <step time="2008-09-26 00:03:20">12321</step>If you can't use XML to solve the problem, then you can scan backwards in the file (using random access file or file buffer) until you find a '<' character which is followed by an '/' character. You can't have CDATA after the closing tag of the document element, and comments and processing instructions have different characters following the '<'.

  • How to convert java class file version without decompiling

    Hi,
    Oracle R12.1.3 i am having illegal access error while try to access the class file version Java 1.3 uses major version 47,So how to convert the class file version without using decompiling.
    Current java version is 1.6.0_07
    Is there any tool or API for converting class file version?
    Thanks,
    Selvapandian T

    Beside this I wonder where you get your error from since AFAIK 12c comes with java 1.6.
    Well wonder no more!
    OP isn't using Oracle 12c database.
    They are using Oracle R12.1.3 - which is the E- Business Suite.

  • How to put the swf in sub directory

    Would you guys let me know how to put the *.swf file which
    has *.flv in sub directory other than root.
    I've tried many things none of them working.
    a regular *.swf are OK. But if that swf file related with
    *.flv. that Swf has to be in root directory on the server.
    if I put that swf in sub directory such as /swf then it's not
    working.
    Please, help me out.

    Hi,
    It looks like this is for the certification, so I won't give you that much helpt. But you could use a modern IDE to do what you want, or use ant (http://ant.apache.org/) for building.
    /Kaj
    Ps. It looks like your classpath is wrong when you try to run the program.

  • How to put the file name in notepad file

    dear frank,
    how to put the file name in notepad file via power shell. I mean i want to put the file name in that notepad file
    for example,
    my file name is ABL and in this file data is
    02/06/2015,180.00,182.00,176.01,180.50,1575500
    02/06/2015,4.20,4.20,4.20,4.20,500
    02/06/2015,113.50,113.70,112.91,113.09,157800
    02/06/2015,682.01,695.90,682.00,683.19,4250
    02/06/2015,213.98,215.00,213.00,214.87,326200
    02/06/2015,21.52,21.65,21.52,21.60,4000
    02/06/2015,111.00,111.25,108.25,108.91,17100
    02/06/2015,52.00,52.00,52.00,52.00,500
    and i want to data in this form
    ABL,02/06/2015,180.00,182.00,176.01,180.50,1575500
    ABL,02/06/2015,4.20,4.20,4.20,4.20,500
    ABL,02/06/2015,113.50,113.70,112.91,113.09,157800
    ABL,02/06/2015,682.01,695.90,682.00,683.19,4250
    ABL,02/06/2015,213.98,215.00,213.00,214.87,326200
    ABL,02/06/2015,21.52,21.65,21.52,21.60,4000
    ABL,02/06/2015,111.00,111.25,108.25,108.91,17100
    ABL,02/06/2015,52.00,52.00,52.00,52.00,500
    There are many file like this that i want to be edit
    plese tell me how can i do it, i think it is possible via windows power shell.
    thanks in advance.

    Hi
    Just for completeness, what version of VB.NET are you using?
    Here is a complete project to copy all the files with the added "ABL," at the start of each line.  You need to start a new Project with a BLANK default Form1, and replace all of Form1 code with the code below. When you run this project, you
    need to use the 2 buttons to set up the ORIGINAL file folder and a folder to place the copies. You need to check if the file EXTENSION is correct (I assumed txt), and check the text to add to each line is correct.  Once all is set up you should have a
    big red button to start the operation.
    NOTE: it is important that you try this out on a copy of some of the files to verify accuracy BEFORE trying on original files. Make sure you have a good back up of the original files before doing anything else.
    ' new project with default BLANK Form1
    ' replace all Form1 code with this code
    ' WARNING: make sure you have a backup of
    ' any files you use this application to
    ' operate on.
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class Form1
    Dim OrigFileFolderPath As String = Nothing
    Dim CopyToFolderPath As String = Nothing
    Dim lab1, lab2, lab3 As New Label
    Dim tb1, tb2, tb3 As New TextBox
    Dim b1, b2, b3, b4 As New Button
    Dim fb As New FolderBrowserDialog
    Dim bgw As New System.ComponentModel.BackgroundWorker
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Me.Size = New Size(731, 300)
    With lab1
    .Text = "Original Files Folder Path"
    .Location = New Point(15, 5)
    End With
    With tb1
    .Width = 560
    .Location = New Point(10, 30)
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = New Font(Me.Font.FontFamily, 12)
    .BorderStyle = BorderStyle.FixedSingle
    .Anchor = AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Right
    End With
    With lab2
    .Text = "Copy Files to Folder Path"
    .Location = New Point(15, 125)
    End With
    With tb2
    .Width = 665
    .Location = New Point(10, 150)
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .Font = New Font(Me.Font.FontFamily, 12)
    .BorderStyle = BorderStyle.FixedSingle
    .Anchor = AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Right
    End With
    With lab3
    .Text = "File Ext"
    .Location = New Point(600, 5)
    .Anchor = AnchorStyles.Top Or AnchorStyles.Right
    End With
    With tb3
    .Text = ".txt"
    .Width = 80
    .Location = New Point(590, 30)
    .BackColor = Color.Khaki
    .ForeColor = Color.Maroon
    .TextAlign = HorizontalAlignment.Center
    .Font = New Font(Me.Font.FontFamily, 12)
    .BorderStyle = BorderStyle.FixedSingle
    .Anchor = AnchorStyles.Top Or AnchorStyles.Right
    End With
    With b1
    .Text = "Choose Original Files Folder Path"
    .AutoSize = True
    .Location = New Point(10, 65)
    End With
    With b2
    .Text = "Choose Copy Files to Folder Path"
    .AutoSize = True
    .Location = New Point(10, 185)
    End With
    With b3
    .Text = "DO THE COPY"
    .AutoSize = False
    .Size = New Size(240, 50)
    .BackColor = Color.Red
    .ForeColor = Color.White
    .Font = New Font(Me.Font.FontFamily, 20, FontStyle.Bold)
    .Location = New Point(420, 80)
    .Anchor = AnchorStyles.Top Or AnchorStyles.Right
    .Visible = False
    End With
    With b4
    .Text = "CANCEL JOB"
    .AutoSize = False
    .Size = New Size(240, 50)
    .BackColor = Color.Red
    .ForeColor = Color.White
    .Font = New Font(Me.Font.FontFamily, 20, FontStyle.Bold)
    .Location = New Point(420, 80)
    .Anchor = AnchorStyles.Top Or AnchorStyles.Right
    .Visible = False
    End With
    Me.Controls.AddRange({lab1, lab2, lab3, tb1, tb2, tb3, b1, b2, b3, b4})
    With bgw
    .WorkerReportsProgress = True
    .WorkerSupportsCancellation = True
    End With
    AddHandler bgw.DoWork, AddressOf bgw_DoWork
    AddHandler bgw.RunWorkerCompleted, AddressOf bgw_Completed
    AddHandler b1.Click, AddressOf b1_Click
    AddHandler b2.Click, AddressOf b2_Click
    AddHandler b3.Click, AddressOf b3_Click
    AddHandler b4.Click, AddressOf b4_Click
    End Sub
    Private Sub b1_Click(sender As Object, e As EventArgs)
    fb.SelectedPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
    fb.ShowNewFolderButton = False
    Dim r As DialogResult = fb.ShowDialog
    If r = Windows.Forms.DialogResult.OK Then
    tb1.Text = fb.SelectedPath
    If IO.Directory.Exists(tb1.Text) AndAlso IO.Directory.Exists(tb2.Text) AndAlso Not (tb1.Text = tb2.Text) Then
    If tb3.Text = Nothing Then
    redo: tb3.Text = InputBox("Enter the file extension that you want to copy/change", "FILE EXTENSION")
    If tb3.Text = Nothing Then GoTo redo
    End If
    b3.Visible = True
    Else
    b3.Visible = False
    End If
    End If
    End Sub
    Private Sub b2_Click(sender As Object, e As EventArgs)
    fb.SelectedPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
    fb.ShowNewFolderButton = True
    Dim r As DialogResult = fb.ShowDialog
    If r = Windows.Forms.DialogResult.OK Then
    tb2.Text = fb.SelectedPath
    If IO.Directory.Exists(tb1.Text) AndAlso IO.Directory.Exists(tb2.Text) AndAlso Not (tb1.Text = tb2.Text) Then
    If tb3.Text = Nothing Then
    redo: tb3.Text = InputBox("Enter the file extension that you want to copy/change", "FILE EXTENSION")
    If tb3.Text = Nothing Then GoTo redo
    End If
    b3.Visible = True
    Else
    b3.Visible = False
    End If
    End If
    End Sub
    Private Sub b3_Click(sender As Object, e As EventArgs)
    b3.Visible = False
    b4.Visible = True
    If Not tb3.Text.StartsWith(".") Then tb3.Text = "." & tb3.Text
    bgw.RunWorkerAsync()
    End Sub
    Private Sub b4_Click(sender As Object, e As EventArgs)
    bgw.CancelAsync()
    End Sub
    Private Sub ReadPWFile(fn As String)
    Dim filename As String = My.Computer.FileSystem.GetName(fn)
    Dim barename As String = IO.Path.GetFileNameWithoutExtension(fn)
    Dim copyto As String = tb2.Text & "\" & filename
    Dim line As String = Nothing
    Dim lines As New List(Of String)
    Using sr As IO.StreamReader = New IO.StreamReader(fn)
    Do
    line = sr.ReadLine()
    If Not line = Nothing Then
    lines.Add(barename & "," & line)
    End If
    Loop Until line = Nothing
    End Using
    Using sw As IO.StreamWriter = New IO.StreamWriter(copyto)
    For Each s As String In lines
    sw.WriteLine(s)
    Next
    End Using
    End Sub
    Private Sub bgw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
    Dim ftc As Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(tb1.Text)
    For Each f As String In ftc
    If bgw.CancellationPending Then
    e.Cancel = True
    Exit For
    End If
    Dim ex As String = My.Computer.FileSystem.GetFileInfo(f).Extension.ToLower
    If My.Computer.FileSystem.GetFileInfo(f).Extension.ToLower = tb3.Text.ToLower Then
    ReadPWFile(f)
    End If
    Next
    End Sub
    Public Sub bgw_Completed(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)
    tb1.Text = Nothing
    tb2.Text = Nothing
    b3.Visible = False
    b4.Visible = False
    MessageBox.Show("Finished copying files", "Job Completed")
    End Sub
    End Class
    Regards Les, Livingston, Scotland

Maybe you are looking for