Using File Object in JavaFX 2.2 to set home directory
Am I going bongers or what? Or is there a bug? Has anyone had this problem with the following line:
File dir = new File(getClass().getResource(".").getFile()); <-- this line is the culprit
Choose.setInitialDirectory(dir);
causing your programme to crash and generate the following error:
java.lang.NullPointerException under JavaFX 2.2?
I know it worked perfectly fine under JavaFX 2.1. So what's changed?
My guess.
With JavaFX 2.1 you were using NetBeans 7.1
With JavaFX 2.2 you are using NetBeans 7.2
Under NetBeans 7.1 the default for JavaFX projects was to run the compiled classes from the file system.
Under NetBeans 7.2 the project can no longer be run from the file system, only from a jar which NetBeans builds using the JavaFX packaging tasks.
When you run a java program from classes off the file system the getResource call will use the file: protocol. Under this protocol directory specifiers like . and .. are valid.
When you run a java program from a jar the getResource call will use the jar: protocol. Under this protocol directory specifiers like . and .. are invalid.
So your upgrade of your NetBeans version just exposed an existing bug in your program which you were unaware of.
If you packaged the same program as a jar and tried to run the jar with a JavaFX 2.1 runtime environment you would have got the same error.
Similar Messages
-
Question about using file objects
Hi,
I have two somewhat related issues in using file objects.
In one app, a simple swing gui that passes a file to a sax parsing class and reports back any errors, if I parse a file using the app, then try to edit the file I'm parsing (in another application) and save, I get an error message. I need to close the parsing app before I can save the file.
In another app I wrote, one that takes a group of files and runs an xslt stylesheet on them, if I select too many files, I get an OutOfMemory error, which leads me to believe that as the files go through multilple processes, they stay alive on the heap.
a file object is basically just a pathname, right? If I'm not using a BufferedWriter, or InputStreamReader or whatever, you can't really close a file...will the notifiy() method let the jvm know that it can let go of the file?
thanks,
bpA File object is just a path, it doesn't open the file or lock it, etc.. But if you are parsing the file, you must be opening (and forgetting to close it).
-
List contents of Directory using File Object.
Hi. I am new to Java.
Right now I want to list the contents of a specific directory. One approach is to use FILE array. But I just cannot get it right. Am i missing out something?Thanks.
My idea was to retrieve the contents of directory and then when the form loads; the contents of directory (only directorys, not files; hence i think i can use isDirectory to check) will be loaded into a listbox (DefaultListModal i supposed)
I ran it without any errors. The Listbox is loaded; but then the listbox reads
Java.lang.String;@1a7508a
What went wrong? -
Hi!
Is their some kind of way one can use File objects in a jar file plz? I have a project which is complete and working well on the IDE but now that I have jarred it, i've come to realize that apparently file objects do not relate well with .jar files. The problem is that the program makes a lot of file manipulations and changing everything to getResource, InputStream etc would be very lengthy. So there's absolutely no way in which one can use File objects in jar files?
Any help would be very much appreciated!
Thanks and regards,
Krt_MaltaYou can use the java.net.JarURLConnection class (use file:/// when creating the URL) to get a URL to a jar entry, create a URI from the URL, and then create a File object on the URI.
Or use java.util.jar.JarFile methods and its associated classes to get jar entry contents.
While you can use these approaches to create File objects from a jar, they are not any easier than what's already been mentioned.
And all you can do is read or delete a jar - jar entries can't be rewritten. -
I have been thrilled to use file sharing for tv programs downloaded on my home pc. I have not been able to sort the program list on the ipad2 to make the list appear in order of showtime or live appearence. Any suggestions?
I have been thrilled to use file sharing for tv programs downloaded on my home pc. I have not been able to sort the program list on the ipad2 to make the list appear in order of showtime or live appearence. Any suggestions?
-
Strange file created in my home directory!
I just recently noticed a zero byte size file created at the root level of my home directory (see below). It's an ip address (from Belize) with what I assume to be a high port at the end of the ip address. It was created back on December 6'th and I have no idea how it got there. I have scanned my desktop with ClamxAV and the free version of Sophos for mac but all comes back clean. Has anyone seen something like this before, should I be concerned? I did not create it and no one but me uses this profile.
-
Getting 'File not found' error while using server object model code
Hi,
I am using server object model code to pull list data in a console application. My machine has standalone installation of SP 2010. I am getting error 'File Not Found', however the same operation is working fine with client object model code.
Code I am using:
string strURL=http://servername/sites/sitename;
SPSite siteObj=new SPSite (strURL); //getting error here.
I have already checked the below,
1. Framework being used is 3.5.
2. I have proper access to site.
3. Running visual studio as admin.
Any help is much appreciated.
thanks
Tarique
thanks and regards Tarique AslamHello Tarique ,
Couple of pints need to check:
1. User running the console application needs to have at least read permission to the SharePoint databases
2. Set application by changing the "Platform target:" option on the "Build" to "Any CPU"
Also refer this similar thread:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2a419663-c6bc-4f6f-841b-75aeb9dd053d/spsite-file-not-found
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
I have downloaded a file from a FTP site into a File object. This file doesn't actually exist the file itself is in memory. Instead of using the renameTo() command to save the file to the hard drive I want to take the file and get its contents and store it in a string object? Im imaging this is something like a FileStream object but im not sure. Here is a snippet that I shows I have successfully downloaded the file off the FTP site and I want to get its contents ands tore it in a string besides saving to a file. Below I am saving the file to a hard drive but I do not want to do this anymore.
String currString = (String)fileListNames.get(c);
currentFile = ftps.download(currString);
File dummy = new File(config.getConfig("billEDIDir") + currString);
fileList[c] = config.getConfig("billEDIDir") + currString;
if(dummy.exists())
dummy.delete();
currentFile.renameTo(dummy);
Thanks for any help!Im creating a Java Service in the webMethods Intergration Tool. Here is the entire class.
****************************CODE************************************
IDataCursor pipelineCursor = pipeline.getCursor();
int count,currCount;
String error = "";
String status = "";
Ftps ftps = null;
File currentFile = null;
Enumeration x;
Enumeration y;
ArrayList fileListNames = new ArrayList();
try
ftps = new Ftps("*******","********","*********");
ftps.setDataPortRange(6100,6199);
ftps.setPassive(true);
ftps.connect();
ftps.setBinary();
ftps.setDir("outbound");
ftps.setDir("KUED");
count = 0;
for (x = ftps.getNameListing(); x.hasMoreElements() ;)
count++;
x.nextElement();
currCount = 0;
for (y = ftps.getNameListing(); y.hasMoreElements() ;)
currCount++;
String m = (String)y.nextElement();
fileListNames.add(currCount - 1,m.toString());
status = ftps.getDirListingAsString();
catch(FtpException fexp)
error = fexp.getMessage();
throw new ServiceException( fexp.toString() );
catch(Exception e)
error = e.getMessage();
throw new ServiceException( e.toString() );
String [] fileList = new String[count];
String [] fileContentList = new String[count];
try
for(int c=0;c<fileListNames.size();c++)
String currString = (String)fileListNames.get(c);
currentFile = ftps.download(currString);
File dummy = new File(config.getConfig("billEDIDir") + currString);
fileList[c] = config.getConfig("billEDIDir") + currString;
if(dummy.exists())
dummy.delete();
currentFile.renameTo(dummy);
//In this string list store the contents of each file downloaded.
fileContentList[c] = "";
ftps.disconnect();
catch(Exception e)
error = e.getMessage();
throw new ServiceException( e.toString() );
IDataUtil.put( pipelineCursor, "status", status );
IDataUtil.put( pipelineCursor, "error", error );
IDataUtil.put( pipelineCursor, "fileList", fileList );
IDataUtil.put( pipelineCursor, "fileContentList", fileContentList );
pipelineCursor.destroy();
****************************CODE************************************ -
Read some HR archive files (object PA_PIDX) using Abap report
Hi experts,
an ABAP program that is supposed to read some HR archive files (object PA_PIDX) but all we can read is the object, we cannot access the individual lines. Please help
My code
Output of the report as well as output of archive program
Cycles comptab. archivés
0000000038
0000000040
0000000044
0000000045
0000000047
0000000050
Cycles comptab. ignorés (pour détails voir protocole de job)
0000000001 Simulation
0000000002 Simulation
0000000003 Simulation
0000000004 Simulation
0000000005 Simulation
.....etc
Please help
Edited by: Blaiso on Apr 1, 2011 5:54 PM
Edited by: Blaiso on Apr 1, 2011 5:59 PM
Moderator message: please post only relevant code parts, your post must be less than 5000 characters to preserve formatting.
Edited by: Thomas Zloch on Apr 2, 2011 9:59 PMHi Ajay,
1. You have to create a separate field catelogus and AIS according to your requirement with the required fields you want . Because the standard structures and field catelogues contains many fields from all tables. So before doing the read operation you have to deactivate the standard AIS and activate your newly created AIS .
2. Can you give some more details for this question to be answered.
3. The important archiving tables used are ARCH_IDX,ARCH_RPRG,ARCH_DEF.
4. While scheduling the Read process in batch mode , it will give you three criterias to be entered.
. Spool Parameters
(ii). Start date
(iii). Archive selection of files.
Unless you enter values for any one of these options , You cannot execute the batch job.
Hope this would help you.
Regards - Swarna. -
Upload an excel file input into an itab,display in ALV using ABAP objects
Requirement:
Create a selection screen which takes an excel file as input with parameters emp id, emp name, salary, mnth, ph no.
Create a database table with the same fields.
The program needs to have two modes. Display mode and update mode.
Display mode only displays the file data in alv grid and update mode updates database table with similar parameters as above and also shows alv grid output.
task is to do using Object oriented approach. This should also have the facility to modify the cell values in ALV grid and once saved then it needs to update the database accordingly.
I have done the same functionality in a report program without using ABAP objects but finding difficulty in using object oriented approach.Please help me as i am new to abap-objects.
Thanks in advance.......Hi,
The selection screen design and all remains the same.
Get all the detials which you need in your final internal table.
This internal table will be used to display in the ALV grid.
The approach remains the same as the normal programing.
Prepare a field catalog table and then use it along with the internal table to display in the grid.
The only change is that instead of FM you will have to make us of classes and their methods.
Firstly you will have to create a screen.
On this screen create a custom control object and give it some name. say for eg. CC_CONTAINER.
This will be a container on which the ALV grid object will be placed.
2 objects are needed to display the grid
CL_GUI_CUSTOM_CONTAINER and CL_GUI_ALV_GRID.
In the PBO of the screen first create an instance of object CL_GUI_CUSTOM_CONTAINER
CREATE OBJECT y_lobj_cont
EXPORTING
container_name = 'CC_CONTAINER'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Then create a instance of the GRID
IF y_lobj_grid IS INITIAL.
CREATE OBJECT y_lobj_grid
EXPORTING
i_parent = y_lobj_cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
Then call the method SET_TABLE_FOR_FIRST_DISPLAY to display the grid.
CALL METHOD y_lobj_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = y_v_lt_exclude
CHANGING
it_outtab = y_li_tbl
it_fieldcatalog = y_li_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Check the example program BCALV_GRID_EDIT for better understanding.
Regards,
Ankur Parab -
Huge file size while using smart objects?
I'm laying out some big panels containing smaller images, so I am adding these using 'File>Place'. However, while the empty panel takes up about 70 MB, placing 3MB worth of smaller images makes the file size explode to a whopping 150MB, making it impossible to fill up the entire board. So far, I've seen file sizes of 500 MB, with Photoshop eating up 50GB swap files. Any idea what is going on here?
(I'm using Photoshop CS4 on OS X 10.7.3)If you are familiar with Indesign and Illustrators and how they handle placed images that can lead to expectations that are not met by Photoshop’s Smart Objects.
But the Smart Object-approach in Photoshop offers other advantages – there is no need to collect the linked images when handing on a file, because they are part of the document.
You may want to check out:
http://feedback.photoshop.com/photoshop_family/topics/please_consider_a_references_tool_to _create_links_to_layers_or_folder_groups -
To extract the users permission on files and folders in sharepoint 2010 using client object model
To extract the users permission on files and folders in sharepoint 2010 using client object model
Hello,
This is sample code to get item level permisison: (Just written in notepad so it is not tested)
public void ItemLevelPermission()
SecurableObject curObj = null;
ListItem curItem = ctx.Web.Lists.GetByTitle("LibraryName").GetItemById(ItemId); -> Use Id of file or folder.
IEnumerable roles = null;
roles = ctx.LoadQuery(
curObj.RoleAssignments.Include(
roleAsg => roleAsg.Member,
roleAsg => roleAsg.RoleDefinitionBindings.Include(
roleDef => roleDef.Name, // for each role definition, include roleDef’s Name
roleDef => roleDef.Description)));
ctx.ExecuteQuery();
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
I want to change 'Modified By' column value of a file that is being uploaded using Client Object Model in SharePoint 2013. The problem is that the version of the file is changing. Kindly help me. The code that I am using is:
using (System.IO.Stream fileStream = System.IO.File.OpenRead(m_strFilePath))
Microsoft.SharePoint.Client.File.SaveBinaryDirect(m_clientContext, str_URLOfFile, fileStream, true);
Microsoft.SharePoint.Client.File fileUploaded = m_List.RootFolder.Files.GetByUrl(str_URLOfFile);
m_clientContext.Load(fileUploaded);
m_clientContext.ExecuteQuery();
User user1 = m_Web.EnsureUser("User1");
User user2 = m_Web.EnsureUser("User2");
ListItem item = fileUploaded.ListItemAllFields;
fileUploaded.CheckOut();
item["UserDefinedColumn"] = "UserDefinedValue1";
item["Title"] = "UserDefinedValue2";
item["Editor"] = user1;
item["Author"] = user2;
item.Update();
fileUploaded.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
m_clientContext.ExecuteQuery();Hi talib2608,
Chris is correct for this issue, when calling update using ListItem.update method, it will increase item versions, using SystemUpdate and UpdateOverwriteVersion will update the list item overwrite version.
these two methods are not available in CSOM/REST, only server object model is available for this.
Thanks,
Qiao Wei
TechNet Community Support -
Hi,
we are using Flash CC an a dedicated windows server with two userprofiles. Each user has its own licence.
If we run a jsfl script singly, this script runs fine.
If we run the same jsfl script on both users we get the error:
"Embedding OLE objects is unsupported. Use File->Import to import media."
I read the article addItem() -> "Embedding OLE objects is unsupported" , but it could not the problem, because the script runs fine singly.
Could it be possible that both users uses the same Flash CC Clipboard ore are there any other shared modules etc?
Best regards
Alexcan you write how to use ?
i write
"import the flash.display.MovieClip; "
still error ahhh
i try to change extends MovieClip instead Spirt
and not error stop(); and gotoAndStop Already
but
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MemoryGame/nextTurn()
at MemoryGame/clickStart()
i got thissssssss TT
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.display.MovieClip;
that i import -
Data upload to .XLSX file - problem using OLE2 object ?
Hi all,
Currently my abap program is able to upload data from .xls excel file to internal table using OLE2 object.
But it is not doing the same with the .XLSX excel 2007 file.
I need to upload data from .XLSX file to internal table using OLE2 objects.
Is it possible ?. If yes kindly help me in solving this issue.Yes it is Possible
Maybe you are looking for
-
How do I add an objectclass to existing LDAP server entry using an ldif file?
I am trying to fix an LDAP server that has been operating with schema check off. I need to add an objectclass to the groups so that some attributes that have been added to the groups will be "legal." From the documentation, the changetype: modify wil
-
Help I would like to send an e-mail to a group of people, I have the group created, but when I drag it to bcc or to- it will not attach. can anymon help me with this?
-
My Late 2008 Aluminum MacBook keeps crashing on new OS X 10.8.1
I recently upgraded my Late 2008 Macbook to Mountain lion. Since doing so, my computer is running really slow and constantly crashes. I cant have more than two programs running at the same time, otherwise the computer will freeze up and i get the "ra
-
How to make line-in come out rear speakers? (SB Live! 5
Card is SB Li've! 5. DE and OS is XP SP2: ================================ I have tried everything that I can think of. It was working fine until I installed a program which screwed up my mixer settings. I have loaded the default mixer settings. Now
-
Hi, Community.. I just received some splendid answers to a question I had. I found that i still have one question.. i have two mail accounts at mac.com.. they are together in my mail account , (separated into two as required in the 'accounts'' tab.)